2
votes

I run some SAS queries monthly and they all take a fairly long time to run. I was wondering if there was any way I can schedule these to run on a certain date each month in a certain order?

Thanks for your help!

2

2 Answers

3
votes

On unix you could set the programs up to run in batch mode with a cron job.

One trick you could use would be to set up a master SAS program to run everything. Make one program that just contains any global variables that need to be changed each month and then call your monthly programs with includes. something like:

%let globalvar1 = ThisMonth;
%let globalvar2 = LastMonth;

%include '/path/to/sas/program1';
%include '/path/to/sas/program2';

Then you run only this one program in batch...it will run them in the correct order and automatically wait for them to finish executing before moving to the next program (setting up separate cron jobs would require you to overestimate how long each one takes so they wouldn't conflict).

This will dump everything into one log file...which may be good or bad. Another option would be to use X to call the program from the OS at each run.

I am not 100% on the syntax but this should work if you use the right syntax for your OS (this could work on unix or windows so you would only have to schedule one program).

At the end of each program just add:

X "Path/to/sas.exe" -batch -noterminal nextProgram.sas

This will let you chain the programs together so that they start the next one running after they finish. Then you just use task scheduler/cron to start "sas.exe -batch -noterminal firstProgram.sas"

3
votes

Depending on what system you are working with, methods may be different.

The main idea is that you may store all queries to a SAS processing file then use system's scheduler (For example, task scheduler for Windows), to run monthly.

A quick help (for Windows): http://analytics.ncsu.edu/sesug/2006/CC04_06.PDF