BookmarkSubscribeRSS Feed
JaySwan
Calcite | Level 5

I have a request to build a SAS Macro that fires off a SAS Program every day, in 10 minute intervals.

I am aware of the &SysDate, &SysDay and &SysTime variables and figure they will be used to calcuate the Day and Time (Not sure I need to worry about the &SysDate), but do not have much experience with SAS Macro's and %Do loops.

I know I'll need to add 10 minutes to the &SysTime variable and basically hold until the system clock and the &SysTime+10Min = the SystemTime.

I'm working on this now, but any insight or code would be helpfull.

Job will be running on UNIX and I am coding in SAS EG.

TIA, Jay

8 REPLIES 8
Bill
Quartz | Level 8

Would it not be wiser to use the Unix scheduler to kick off the program?

FriedEgg
SAS Employee

Unix Scheduler:

Unix$> crontab -e

10 * * * * /path/to/sas -batch -noterminal -config path/to/sasconfig.cfg -sysin /path/to/code.sas -log /path/for/log.log -print /path/for/print.lst

SAS Macro (would not recommend):

%do until(&exception=1);

  %execution_macro

   data _null_;

    slept=sleep(60*10); /*sleep for 10 minutes */

   run;

/* sas statements to catch an exeception to stop loop */

%end;

JaySwan
Calcite | Level 5

Cron and the UNIX Scheduler are not availiable.. Thanks I am looking at the above code(s)...

art297
Opal | Level 21

Could you use EG's own scheduler?  I'm not familiar with it, but an application is described in the paper at: http://www2.sas.com/proceedings/sugi29/156-29.pdf

FriedEgg
SAS Employee

You can access the EG scheduler from the File>Schedule Project (the document above says it is under the Tools drop-down).  I have never used it before but basically anything would be preferable to a constantly running loop to execute a subsequent step once every 10 minutes...

Reeza
Super User

I don't know if this works in Unix but in Windows you can 'pause' sas so 'pausing' for 10 minutes seems easier than trying to figure out the next run by looking at system time.

Definitely a brute force methodology. 

DLing
Obsidian | Level 7

Our outsourced UNIX server admins also removed cron from us, but gave us the 'at' command.  So we use at to re-schedule itself.  Here's an example from the 'at' command man pages:

To have a job reschedule itself,  at  can  be  invoked  from within  the  at-job.  For  example,  this "daily-processing" script named my.daily runs every day (although crontab is a more appropriate vehicle for such work).  Content of the my.daily file:

     # my.daily runs every day
     at now tomorrow < my.daily
     daily-processing

So, if you have access to at,

     change second line to 'at now + 10 minute < ...'

     change daily-processing to 'sas -batch -noterminal .........'

These operating system facilities is usually preferred than having one SAS long session that sleeps for 10 minutes then wakes up to do some stuff and the goes back to sleep.

Ksharp
Super User

Not sure whether it could work.

%do %until(count gt 100);* execute  code for one hundred;

.......................

count+1;

%include 'c:\report.sas';

call sleep(60,10); /*sleep for 10 minutes */

............

%end;

Ksharp

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 8 replies
  • 3860 views
  • 0 likes
  • 7 in conversation