BookmarkSubscribeRSS Feed
vomer
Obsidian | Level 7

Hi Everyone,

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?

Thanks.

8 REPLIES 8
art297
Opal | Level 21

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:

%include "file1.sas";

%include "file2.sas";

%include "file3.sas";

%include "file4.sas";

%include "file5.sas";

%include "file6.sas";

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.

vomer
Obsidian | Level 7

I am running on Windows 7 and SAS 9.2

I am assuming that I create a new SAS file and put those statements in there. Then Schedule that newly created file in task scheduler?

Haikuo
Onyx | Level 15

I would first try to use %include.

for example:

%include "c:\file1.sas";

%include "c:\file2.sas";

...

%include "c:\file6.sas";

Regards,

Haikuo

vomer
Obsidian | Level 7

Thanks HaiKuo and Art! I will give this a try and report back.

You guys are amazing Smiley Happy

art297
Opal | Level 21

Plus, here is a nice paper that addresses a number of issues you may or may not have thought about:

http://analytics.ncsu.edu/sesug/2010/BB02.Zimmerman.pdf

Doc_Duke
Rhodochrosite | Level 12

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.).

Doc Muhlbaier

Duke

Astounding
PROC Star

vomer,

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:

%macro all_6_jobs;

   %include  'C:\file1.sas';

   %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';;

%mend all_6_jobs;

%ALL_6_JOBS

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.

Good luck.

Hima
Obsidian | Level 7

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

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
  • 1005 views
  • 6 likes
  • 6 in conversation