DATA Step, Macro, Functions and more

How to run sas batch job in sas editor ?

Reply
Contributor
Posts: 59

How to run sas batch job in sas editor ?

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

 

 

 

 

 

Contributor
Posts: 39

Re: How to run sas batch job in sas editor ?

Posted in reply to wtien196838

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.

 

 

Contributor
Posts: 39

Re: How to run sas batch job in sas editor ?

Posted in reply to Pamela_JSRCC

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.

Super User
Posts: 5,424

Re: How to run sas batch job in sas editor ?

Posted in reply to wtien196838
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
SAS Employee
Posts: 18

Re: How to run sas batch job in sas editor ?

Posted in reply to wtien196838

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.

Contributor
Posts: 59

Re: How to run sas batch job in sas editor ?

Posted in reply to DavidPope

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.

Ask a Question
Discussion stats
  • 5 replies
  • 405 views
  • 1 like
  • 4 in conversation