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
Opal | Level 21

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
Opal | Level 21

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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 5 replies
  • 268 views
  • 1 like
  • 3 in conversation