Macro Used Real Time

From sasCommunity
Jump to: navigation, search

Q: How do I add an elapsed-time note used real time to my macro?

A: Add these statements to your macro:

Author: Ronald_J._Fehd

Note: macro names in lower case for port to any linux/unix system.

%MACRO mymacro
      (data =
       ...
)/ des = 'site: description: purpose:'
 /*  ** store source /* */
;/* modifications:
Who date description
RJF 2012-July-09 added datetime-stamp @ end
**************** */
%local _C_TimeStart _C_TimeEnd;
%let   _C_TimeStart = %sysfunc(datetime(),hex16.);

At the end of the macro add these statements to write the note:

%let _C_TimeEnd = %sysfunc(datetime(),hex16.);     
%Put note: &SysMacroName used real time %sysfunc
           (putn(&_C_TimeEnd.x-&_C_TimeStart.x,time12.3));
%mend mymacro;

log:

note: CALLMACR used real time  0:00:00.016

References

This trick is used by macros:

--Ronald_J._Fehd macro.maven == the radical programmer 14:30, 12 May 2012 (EDT)