Sometimes, I wanted to compare the efficiency between two approaches. I used following codes to get the program execution run-time:
%let _sdtm=%sysfunc(datetime());
*** SAS codes ***;
%let _edtm=%sysfunc(datetime());
%let _runtm=%sysfunc(putn(&_edtm - &_sdtm, 12.4));
%put It took &_runtm second to run the program;
%let _edtm=%sysfunc(datetime());
%let _runtm=%sysfunc(putn(&_edtm - &_sdtm, 12.4));
%put It took &_runtm second to run the program;
It is also very easy to print the date and time:
%put %sysfunc(putn(&_sdtm, datetime20.));
Very useful, I pasted it simply into my progam.
ReplyDeleteI concur. Thank you for helping random people.
ReplyDeleteHere is how you can create and embed simple SAS timer into your SAS code: SAS timer - the key to writing efficient SAS code .
ReplyDeleteHi there I have multiple macro call to some tasks in one data step. and I need to get the time taken by each of them individually.
ReplyDeleteI tried the above code for each of them but it is not giving desired results.
data _NULL_;
%let START_TIME=%sysfunc(datetime());
call execute ('%exesql(sqlstatement='||'truncate table STAGING.&TableName);');
call execute ('%exesql(sqlstatement="&&InsertStmt");');
%let END_TIME=%sysfunc(datetime());
call execute('%Audit('||'&START_TIME'||','||'&END_TIME'||','||'&TableName'||',Load_Sub_Claim_Feed,Y);');
%let START_TIME=%sysfunc(datetime());
call execute ('%exesql(sqlstatement='||'truncate table STAGING.&TableName);');
call execute ('%exesql(sqlstatement="&&InsertStmt");');
%let END_TIME=%sysfunc(datetime());
call execute('%Audit('||'&START_TIME'||','||'&END_TIME'||','||'&TableName'||',Load_Sub_Claim_Feed,Y);');
call execute ('%exesql(sqlstatement='||'truncate table STAGING.&TableName);');
call execute ('%exesql(sqlstatement="&&InsertStmt");');
run;