****************************************************************************************************
*                                           PROGRAM OVERVIEW
****************************************************************************************************
*
* PROGRAM: ms_outputruntimes.sas 
*
* Created (mm/dd/yyyy): 06/30/2019
* Last modified: 
* Version: 1.0
*
*--------------------------------------------------------------------------------------------------
* PURPOSE:
*  This utility macro output the dataset &runid._runtimes
*
*  Program inputs:                                                                                   
*                                     
*  Program outputs: 
*
* PARAMETERS:
*	- timevar: macro variable holding start time
*   - step: description of step
*	- group: scenario
*	- monitoringperiod: monitoring period ID
*
*  Programming Notes:                                                                                
*                                                                           
*
*--------------------------------------------------------------------------------------------------
* CONTACT INFO: 
*  Sentinel Coordinating Center
*  info@sentinelsystem.org
*
*--------------------------------------------------------------------------------------------------
*  CHANGE LOG: 
*
*   Version   Date       Initials	   Comment (reference external documentation when available)
*   -------   --------   --------   ---------------------------------------------------------------
*
***************************************************************************************************;

%macro ms_outputruntimes(timevar=, step=, group=, monitoringperiod=);

	%put =====> MACRO CALLED: ms_outputruntimes v1.0;

	data msoc.&runid._runtimes;
		set msoc.&runid._runtimes end=eof;
		output;
		if eof then do;
			format start stop datetime21.2; 
			start=input("&&&timevar.",best.); 
			stop=input("&STOP.",best.);   
			format Seconds $20.;
			Seconds=put(int(&stop.-&&&timevar.),best.)||" s";
			step = "&step.";
			group = "&group.";
			monitoringperiod = "&monitoringperiod.";
			startdate = "&&&timevar.date";
			starttime = "&&&timevar.time";
			enddate = "&&&timevar.enddate"; 
			endtime = "&&&timevar.endtime";
			runtime = strip("&hours. h &minutes. m &seconds. s");
			drop start stop seconds;
			output;
		end;
	run;

	%put NOTE: ********END OF MACRO: ms_outputruntimes v1.0 ********;

%mend;