BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
hhchenfx
Rhodochrosite | Level 12

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 ();
1 ACCEPTED SOLUTION

Accepted Solutions
hhchenfx
Rhodochrosite | Level 12

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;

View solution in original post

6 REPLIES 6
SASKiwi
PROC Star

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.

hhchenfx
Rhodochrosite | Level 12

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;
Reeza
Super User

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);
hhchenfx
Rhodochrosite | Level 12

Hi Reeza,

It is exactly what I am looking for.

Thanks,

HHC

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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 lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2213 views
  • 7 likes
  • 4 in conversation