**************************************************************************************************** * PROGRAM OVERVIEW **************************************************************************************************** * * PROGRAM: ms_time.sas * * Created (mm/dd/yyyy): 07/31/2014 * Last modified: 02/06/2015 * Version: 1.1 * *-------------------------------------------------------------------------------------------------- * PURPOSE: * This program is composed of two macros: ms_starttimer and ms_stoptimer; * * Program inputs: * * Program outputs: * * PARAMETERS: * * ms_starttimer(START=) * START=Name of the macro variable that will hold the time. * Example: %ms_starttimer(START=MAINSTART) * * ms_stoptimer(START=) * START=Reference to the name of the macro variable that will hold the time. * Example: %ms_stoptimer(START=&MAINSTART.) *Notice the use of & and . * * Programming Notes: * * * *-------------------------------------------------------------------------------------------------- * CONTACT INFO: * Mini-Sentinel Coordinating Center * info@mini-sentinel.org * *-------------------------------------------------------------------------------------------------- * CHANGE LOG: * * Version Date Initials Comment (reference external documentation when available) * ------- -------- -------- --------------------------------------------------------------- * 1.1 02/06/15 SL(EM) Put statement was modified in ms_starttimer to display start * date and time in the log. * ***************************************************************************************************; %macro ms_starttimer(START=); %put =====> MACRO CALLED: ms_time v1.1 => ms_starttimer; %global &START.; /*Set macro variables for Query dates*/ data _NULL_; temp=DATETIME(); call symputx("&START.",temp); call symputx("STARTDATE",put(datepart(temp),date9.)); call symputx("STARTTIME",put(timepart(temp),time4.)); run; %put Execution started on &STARTDATE. at &STARTTIME.; %put NOTE: ********END OF MACRO: ms_time v1.1 => ms_starttimer ********; %mend; %macro ms_stoptimer(start=); %put =====> MACRO CALLED: ms_time v1.0 => ms_stoptimer; %put "&start."; %global STOP; %global hours; %global minutes; %global seconds; %global totalseconds; data _NULL_; temp=DATETIME(); seconds=temp-&start.; hours=int(seconds/3600); minutes=int((seconds-hours*3600)/60); seconds2=int((seconds-hours*3600-minutes*60)); call symput("STOP",put(temp,best.)); call symput("hours",put(hours,4.0)); call symput("minutes",put(minutes,2.0)); call symput("seconds",put(seconds2,2.0)); run; %PUT TOTAL RUN TIME was &hours. h &minutes. m &seconds. s; %put NOTE: ********END OF MACRO: ms_time v1.0 => ms_stoptimer ********; %mend;