Hi Everyone,
I have a code that runs every minutes.
I want to add to that code a section (which contain quite a few data steps) that should be run every hour at 00:01 (hh:mm).
Look like this added part could be something a macro inside the big one.
Can you please help me with that?
Many thanks,
HHC
%MACRO _BREAK() ;
%DO %WHILE ( %sysevalf(%sysfunc(time())<'16:00:08't,boolean) ) ;
/*------ADDED part that run every hour---------*/
/*My MAIN CODE*/
%*Sleep until 5 seconds after the start of the next minute ;
%put %sysfunc(wakeup("%sysfunc(putn(%eval(%sysfunc(intnx(minute,"%sysfunc( time(), time )"t,1))+5),time.))"t));
%end ;
%mend ;
Thank you all.
I think I got it as below.
HHC
%MACRO _BREAK() ;
%DO %WHILE ( %sysevalf(%sysfunc(time())<'16:00:08't,boolean) ) ;
/*------ADDED part that run every hour---------*/
%let now=%sysfunc(time());%let hh=%sysfunc(hour(&now),z2.);%put &now;%put &hh;
%let mm=%sysfunc(minute(&now),z2.);
%put &mm;
%macro run_hourly;
%if &mm=1 %then %do;
%put 'HERE we go';
%end;
%mend;
%run_hourly;
/*My MAIN CODE*/
%*Sleep until 5 seconds after the start of the next minute ;
%put %sysfunc(wakeup("%sysfunc(putn(%eval(%sysfunc(intnx(minute,"%sysfunc( time(), time )"t,1))+5),time.))"t));
%end ;
%mend ;
If something needs to run at very specific times I would suggest using an actual scheduling program to start a SAS batch job at the given time.
What hours does this process need to run for? Continuously, or only for certain hours and / or on certain days?
Hi,
My main code run every minutes.
The added section need to run inside this main code but only need to be executed every hour (instead of every minute).
That's why I will can't schedule that part as a separate job.
Thanks,
HHC
Is your hourly processing related to your "by minute" processing? Does one rely on the other or not? If there is no interaction between the minute and the hourly processing then running to two separately is an option.
Also you didn't really answer my question regarding over what time periods does your process run. Does it run 24 hours per day, every day, or only for certain hours on certain days? The more hours the processing runs, the more robust and reliable it has to be.
Thank you all.
I think I got it as below.
HHC
%MACRO _BREAK() ;
%DO %WHILE ( %sysevalf(%sysfunc(time())<'16:00:08't,boolean) ) ;
/*------ADDED part that run every hour---------*/
%let now=%sysfunc(time());%let hh=%sysfunc(hour(&now),z2.);%put &now;%put &hh;
%let mm=%sysfunc(minute(&now),z2.);
%put &mm;
%macro run_hourly;
%if &mm=1 %then %do;
%put 'HERE we go';
%end;
%mend;
%run_hourly;
/*My MAIN CODE*/
%*Sleep until 5 seconds after the start of the next minute ;
%put %sysfunc(wakeup("%sysfunc(putn(%eval(%sysfunc(intnx(minute,"%sysfunc( time(), time )"t,1))+5),time.))"t));
%end ;
%mend ;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.