02-01-2012 02:11 PM
I am a new SAS user and I run 6 seperate sas files on a monthly basis.
file1.sas ---> file6.sas
I have to run these files in a particular sequence and currently, I do this manually.
Is there any way I can setup automation which will run the sas files in the order I want monthy?
02-01-2012 02:18 PM
You are asking multiple questions and the answers may be dependent upon the type of system you are on.
You can always just have a driver program that has 6 %include statements, like:
and then save that as a seventh program. As for running it monthly, if you are on Windows, I've had good success using Window's Scheduler.
02-02-2012 10:06 AM
One thing that Art and Haikou didn't mention is that the %include approach will give you one giant log file unless you use PROC PRINTTO to redirect it within each program.
An alternate approach is to create a Windows batch file that contains the SAS execution command and put that in once for each program. You can find the syntax for your particular configuration by looking at the file association with the batch submission. (I don't have windows 7, but in XP, it is in the windows explorer --> fools --> folder options --> file types and then go to SAS and click advanced and edit for the batch command. You can also find the options in the SAS Companion for Windows.).
02-02-2012 12:59 PM
Here are two more considerations. First, look at whether the option SOURCE2 is in place or not. It determines whether %included lines get printed to the log or not. That can nearly double the size of the log so you may want to turn it off.
Second, it's possible from your post that each job depends on the one before completing successfully. If that's the case, you could modify the program:
%if &syserr=0 %then %include 'C:\file2.sas';;
%if &syserr=0 %then %include 'C:\file3.sas';;
%if &syserr=0 %then %include 'C:\file4.sas';;
%if &syserr=0 %then %include 'C:\file5.sas';;
%if &syserr=0 %then %include 'C:\file6.sas';;
Look up the possible values for &SYSERR to see if requiring 0 is too stringent for your purposes. There are other slightly less strict possibilities.
02-01-2012 04:53 PM
This can be acheived using crontab from Unix prompt. If you have access to unix log in and type crontab -e to check access.
Next you need to create a shell script to invoke the SAS program and schedule it from crontab using the format below. I have been doing this for a while this has reduced lot of manual effort.
Syntax for crontab:
Minute Hour Day of Month Month Day of Week Command