Did you know that you
can use the WAKEUP function to put a SAS program to sleep and specify when it
is to resume executing?
The WAKEUP function directs SAS to put your program to sleep
for the duration that you specify within the function. When that duration
has passed, your SAS program wakes up and continues to execute, starting with
the statements found directly after the statement containing the WAKEUP
function.
You can specify a date-time value, a time (in hours), or the
number of seconds before/after midnight for SAS to wait until waking up and
running the rest of your program. Here is an example of each:
data _null_;
dozeuntil = wakeup("04JUL2017:12:00:00"dt);
put "The
4th of July picnic is just starting.";
run;
data
_null_;
dozeuntil = wakeup("22:30:00"t);
put "Time for the Jimmy Kimmel Live show!";
run;
data _null_;
dozeuntil = wakeup("22:30:00"t);
put "Time for the Jimmy Kimmel Live show!";
run;
data _null_;
dozeuntil = wakeup(-7200);
put "It
is 2-hours until midnight!";
run;
data _null_;
dozeuntil = wakeup(7200);
put "It
is 2-hours past midnight!";
run;
The first DATA _NULL_ step will continue executing on July
4, 2017 at 12-noon. The second will
execute every night at 11:30pm. The
third DATA _NULL_ step will execute every evening at 10:00pm. The last one will execute every morning at
2:00am.
There are more nuances to the WAKEUP function than can be
covered in this publication; including limits on the durations that you can
specify. Check out the online
documentation on support.sas.com to
get more information on the WAKEUP function.
Best
of luck in all your SAS endeavors!
---MMMMIIIIKKKKEEEE
(aka Michael A. Raithel)
Author of the new cult
classic for computer programmers: It Only Hurts When I
Hit <ENTER>
Print edition: http://tinyurl.com/z8bzx2e
Kindle edition: http://tinyurl.com/zypgqa7
The hack above is an
excerpt from the book: Did
You Know That? Essential Hacks for Clever SAS Programmers
Print edition: http://tinyurl.com/z8bzx2e
Kindle edition: http://tinyurl.com/zypgqa7
No comments:
Post a Comment