BookmarkSubscribeRSS Feed
🔒 This topic is locked. We are no longer accepting replies to this topic. Need further help? Please sign in and ask a new question.
SAS_Tipster
Moderator

A couple of useful things to do with the current time:

1. Put it at the top and bottom of your program for a quick & easy way of seeing how long a program took to execute.

  e.g.
  %let datetime_start = %sysfunc(TIME()) ;
  %put START TIME: %sysfunc(datetime(),datetime14.);
  ... program code ...
  %put END TIME: %sysfunc(datetime(),datetime14.);
  %put PROCESSING TIME:  %sysfunc(putn(%sysevalf(%sysfunc(TIME())-&datetime_start.),mmss.)) (mm:ss) ;

2. It's also useful to put this in a footnote for output that will be archived.

  e.g.
  footnote2 "%sysfunc(datetime(),datetime14.)";

This tip was originally posted by Robert Matthews on sasCommunity.org. 

1 REPLY 1
Tom
Super User Tom
Super User

Note that you should use DATETIME() function instead of TIME() so that you can allow for periods that cross from one day into another.

%let datetime_start = %sysfunc(datetime()) ;
%put START TIME: %sysfunc(putn(&datetime_start,datetime19));
  ... program code ...
%let datetime_end = %sysfunc(datetime()) ;
%put END TIME: %sysfunc(putn(&datetime_end,datetime19));
%let run_time = %sysevalf(&datetime_end - &datetime_start);
%put PROCESSING TIME:  %sysfunc(putn(&run_time,mmss)) (mm:ss);

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Visit a random SAS tip This SAS Tips board is not open for replies or comments, but we welcome your feedback and questions. Have a question or comment about this tip? Start a new topic in one of our discussion boards, and reference this tip topic.
Discussion stats
  • 1 reply
  • 2055 views
  • 3 likes
  • 2 in conversation