BookmarkSubscribeRSS Feed
wtien196838
Quartz | Level 8

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

 

 

 

 

 

5 REPLIES 5
Pamela_JSRCC
Quartz | Level 8

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.

 

 

Pamela_JSRCC
Quartz | Level 8

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.

LinusH
Tourmaline | Level 20
If you failed, let us know what you tried, and what symptoms (error message etc).

A simple way to accomplish this is to do %include from a "master" SAS program.

See how to execute SAS in batch / background in the SAS Companion for you environment.
There have also been some threads on these communities where you should be able to find directions.
Data never sleeps
DavidPope
SAS Employee

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.

wtien196838
Quartz | Level 8

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.

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!

How to Concatenate Values

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.

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
  • 5 replies
  • 1271 views
  • 1 like
  • 4 in conversation