Production Ready Macros for SAS Application Developers
mp_perflog.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Logs the time the macro was executed in a control dataset.
4  @details If the dataset does not exist, it is created. Usage:
5 
6  %mp_perflog(started)
7  %mp_perflog()
8  %mp_perflog(startanew,libds=work.newdataset)
9  %mp_perflog(finished,libds=work.newdataset)
10  %mp_perflog(finished)
11 
12 
13  @param label Provide label to go into the control dataset
14  @param libds= Provide a dataset in which to store performance stats. Default
15  name is <code>work.mp_perflog</code>;
16 
17  @version 9.2
18  @author Allan Bowe
19  @source https://github.com/Boemska/macrocore
20 
21 **/
22 
23 %macro mp_perflog(label,libds=work.mp_perflog
24 )/*/STORE SOURCE*/;
25 
26  %if not (%mf_existds(&libds)) %then %do;
27  data &libds;
28  length sysjobid $10 label $256 dttm 8.;
29  format dttm datetime19.3;
30  call missing(of _all_);
31  stop;
32  run;
33  %end;
34 
35  proc sql;
36  insert into &libds
37  set sysjobid="&sysjobid"
38  ,label=symget('label')
39  ,dttm=%sysfunc(datetime());
40  quit;
41 
42 %mend;