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

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
Barite | Level 11

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
Barite | Level 11

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
Barite | Level 11

Hi Reeza,

It is exactly what I am looking for.

Thanks,

HHC

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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