04-21-2016 06:58 PM
Dear SAS community users,
Right now I have 5 sas programs: the first four collect data and the fifth one picks up data and creates excel report.
I need to open pc sas to run one by one in order (some programs connect to remote server).
How can I make a batch program to run in sas environment ? I tried to gather all 5 into windows batch .bat to execute but it failed.
Thanks for your solution.
04-21-2016 08:41 PM
I've just done something similar to get around some problems sending email with our new 64-bit SAS version. The previous version is still installed, so I created a batch file to execute that version of sas. The syntax was something like
cd /d [path with program.sas]
[path for 32-bit sas files]\sasexe -sysin program.sas -config [path for config file]\[filename].cfg
I can run it from the command prompt and, more importantly for my purposes, launch it using the Windows scheduler. I only ran a single program file, but would hope that I could add a 2nd, 3rd and 4th if necessary.
Perhaps if you posted your code, we could see what may be the problem.
04-21-2016 08:49 PM
By the way, I was assuming that you are not using Enterprise Guide. It has "process flows" that allow you to group modules together and run with a single "command" from within the EG project. You can also use EG to schedule the process flow to run from the Windows scheduler. That's how my stuff used to run.
04-22-2016 02:03 AM
04-22-2016 11:03 AM
If one program relies on the other programs in order to complete the entire job I would suggest you take your 5 SAS programs and include them in a single new SAS Macro based program which uses the above mentioned %include to execute each program and then write some addition error checking macro code to ensure program 1 ran successfully prior to calling the %include for the second program.
Then schedule the one program as mentioned above.
04-22-2016 01:20 PM
Thanks for all suggestions. DavidPope has some ideas which are similar to my thought.
I explain a little about my programs.
I ran PC SAS 9.3 and connect to unix server to get data from oracle database.
A sample of my program as follows:
options source2 symbolgen mprint;
%include (macro library);
%include (sub programs );
proc printto logs = ... lst=... run;
data aaa ;
proc sql ;
connect to oracle ...
data bbb ;
manipulate data ..... ;
proc printto; run;
I create window bat file xxx.bat with:
start /w "<sas path>"\sas.exe -sysin "<..path>"\program1.sas -log c:\temp\prg.log -lst c:\temp\prg.lst
My problem for this window bat file:
it can not import source of %include inside each sas program
it can not write out the special log file inside each program
This program is working fine separately in sas environment.
I want to create a sas bat program such that
and run it in sas environrment (Local SAS), then it connects to remote server.