Hi Everyone,
Inside a macro (which run every minutes), I want to run a code only when minutes = 0,5,10...45,50,55.
I can get away with the OR statement as below.
However, I would like to know if there is any "cooler" way to get it don?
Thanks
HHC
%macro time ();
data _null_;
call symput('hh', hour(time()));
call symput('mm', minute(time()));
run;
%if &mm =2 or &mm =5 or &mm =10 or &mm = 15 %then %do;
%put &mm.;
%end;
%mend;
%time ();
The problem is that my outer macro is already use the sleep function.
So I can't do sleep for the inner code.
Anyway, I do it the long way.
Thank you all for helping
HHC
%let mm = %sysfunc(minute(%sysfunc(time())));
%IF &mm=0 or &mm=5 or &mm=10 or &mm= 15 or &mm=20 or &mm=25 or &mm=30 or &mm=35 or &mm=40 or &mm=45 or &mm=50 or &mm=55
%THEN %DO;
What OS do your SAS sessions run on? The SLEEP function or the Windows-only WAKEUP function are likely to be useful here. How long does your repeating code run for? I'd suggest using a DO loop, using the SLEEP function to pause between loops.
Put your code in a batch program and use the system's scheduler (e.g. cron on UNIX).
The problem is that my outer macro is already use the sleep function.
So I can't do sleep for the inner code.
Anyway, I do it the long way.
Thank you all for helping
HHC
%let mm = %sysfunc(minute(%sysfunc(time())));
%IF &mm=0 or &mm=5 or &mm=10 or &mm= 15 or &mm=20 or &mm=25 or &mm=30 or &mm=35 or &mm=40 or &mm=45 or &mm=50 or &mm=55
%THEN %DO;
Or do a calculation with SYSFUNC and MOD?
%macro test(mm=);
%IF %sysfunc(mod(&mm, 5))= 0
%THEN %put mm=&mm;
%mend;
%test(mm=0);
%test(mm=6);
%test(mm=10);
Hi Reeza,
It is exactly what I am looking for.
Thanks,
HHC
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.