08-23-2011 11:06 AM
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.
08-23-2011 11:16 AM
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):
slept=sleep(60*10); /*sleep for 10 minutes */
/* sas statements to catch an exeception to stop loop */
08-23-2011 01:10 PM
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
08-23-2011 01:26 PM
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...
08-23-2011 01:58 PM
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.
08-23-2011 02:25 PM
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
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.
08-24-2011 12:07 AM
Not sure whether it could work.
%do %until(count gt 100);* execute code for one hundred;
call sleep(60,10); /*sleep for 10 minutes */