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);

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 1739 views
  • 3 likes
  • 2 in conversation