Saulius S
Saulius S

Reputation: 401

Batching SAS jobs

I'm looking for a simple solution which would enable batching SAS programs, which would run directly from cmd, e.g., "C:\Program Files\SASHome2\SASFoundation\9.4\sas.exe" -CONFIG "C:\Program Files\SASHome2\SASFoundation\9.4\nls\en\sasv9.cfg" -sysin "C:\Users\Documents\sas\Run_Program.sas" -LOG "C:\Users\Documents\sas\f2.log"

However the problem is that i have two SAS files - one representing config, and the second - being program (config file loads particular data sets, global variables, etc...).

Is there a simple solution how i could automate program running process from cmd using current file structure.

Other considered ideas: i have considered creating new (dynamic) sas file batch.sas with it's content %inc "config.sas"; %inc "program.sas" where "program.sas" is dynamic argument provided for every run.

Upvotes: 0

Views: 456

Answers (2)

Allan Bowe
Allan Bowe

Reputation: 12691

If I understand correctly - you are looking to run the config.sas file before the program.sas file? Your suggestion of doing so via %inc is a good one, another approach would be to call your config.sas file on startup by using it as an autoexec, eg as follows:

"C:\Program Files\SASHome2\SASFoundation\9.4\sas.exe"  
  -CONFIG "C:\Program Files\SASHome2\SASFoundation\9.4\nls\en\sasv9.cfg" 
  -sysin "C:\Users\Documents\sas\Run_Program.sas" 
  -LOG  "C:\Users\Documents\sas\f2.log" 
  -autoexec "C:\Users\Documents\sas\config.sas"

An autoexec file runs once, when the SAS session is initialised. Your config.sas file could start by calling any relevant / existing autoexec(s) if needed.

Upvotes: 1

Joe
Joe

Reputation: 63424

The autoexec solution is a reasonable one, but I think that unless you are always (in every single SAS program/session you ever run) loading exactly the same config, that ultimately the right way to do this is the same way c programs have done this for decades with header files.

If you have a config.sas that loads datasets for a particular program, that program should include %include config.sas at the top. Then you just batch the program.

Upvotes: 1

Related Questions