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.
Regards,
William
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.
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.
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.
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 ...
quit;
run;
...
data bbb ;
set aaa;
manipulate data ..... ;
run;
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
%include (<path>\program1.sas)
%include (<path>\program2.sas)
............................
and run it in sas environrment (Local SAS), then it connects to remote server.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.