Batch Submit

Accepted Solution Solved
Reply
Contributor
Posts: 30
Accepted Solution

Batch Submit

Hello All,

I am looking at trying to write a .BAT file that would allow me to run multiple SAS programs in a specific order.  I am having some trouble finding an adequate resource online that can provide me with the help that I need.

The programs that I am trying to run involve recreating datasets with newly imported data into a SAS Library.

Any help you can provide me would be greatly appreciated.

Thanks!


Accepted Solutions
Solution
‎01-29-2014 05:45 PM
Super User
Posts: 3,256

Re: Batch Submit

The way I usually approach SAS jobs in batch mode that run multiple SAS programs is I create a controlling SAS program to run all the required SAS programs.

For example you could create a SAS program called CONTROL.SAS and this program contains %INCLUDE statements to run all of the others:

%include "pgm1.sas";

%include "pgm2.sas";

%include "pgm3.sas";

etc....

The advantage of this approach is that you only need to run the CONTROL.SAS program to run all required programs and you end up with just one SAS log file for the entire batch job. This makes things easy when scheduling batch jobs as well.

You may then not require a .BAT program as you can run your complete job from a (Windows) command line like so:

C:\path\to\sas.exe -batch -sysin "C:\path\to\CONTROL.SAS" -log "C:\path\for\log.log" -lst "C:\path\for\list.lst"

View solution in original post


All Replies
Solution
‎01-29-2014 05:45 PM
Super User
Posts: 3,256

Re: Batch Submit

The way I usually approach SAS jobs in batch mode that run multiple SAS programs is I create a controlling SAS program to run all the required SAS programs.

For example you could create a SAS program called CONTROL.SAS and this program contains %INCLUDE statements to run all of the others:

%include "pgm1.sas";

%include "pgm2.sas";

%include "pgm3.sas";

etc....

The advantage of this approach is that you only need to run the CONTROL.SAS program to run all required programs and you end up with just one SAS log file for the entire batch job. This makes things easy when scheduling batch jobs as well.

You may then not require a .BAT program as you can run your complete job from a (Windows) command line like so:

C:\path\to\sas.exe -batch -sysin "C:\path\to\CONTROL.SAS" -log "C:\path\for\log.log" -lst "C:\path\for\list.lst"

Super User
Posts: 5,431

Re: Batch Submit

One disadvantage if using the %include concept, is that log file can tend to big, and hard go through.

So you may want to add som PROC PRINTTO logic to have each programs log file stored seperately.

How to create .BAT scripts is not really in scope for these forums, but if you want more detail about how to call SAS from a command line (in batch/background), see the Companion for Windows in the documentation.

SAS(R) 9.4 Companion for Windows, Second Edition

Data never sleeps
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 330 views
  • 3 likes
  • 3 in conversation