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,

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 ;

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
hhchenfx
Barite | Level 11

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 ;

View solution in original post

5 REPLIES 5
ballardw
Super User

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.

SASKiwi
PROC Star

What hours does this process need to run for? Continuously, or only for certain hours and / or on certain days?

hhchenfx
Barite | Level 11

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

 

SASKiwi
PROC Star

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.

hhchenfx
Barite | Level 11

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 ;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 5 replies
  • 790 views
  • 1 like
  • 3 in conversation