Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running multiple sas programs

Status
Not open for further replies.

riskassure

Programmer
May 6, 2005
33
US
Hi, how do I run a saved sas program from my current sas program? Is there a way to reference a sas program and execute it by somehow calling its name and address?

Thanks in advance,

Chi

~~CW~~
 
you could try the following

FILENAME Raw_Data 'T:\Robbie\Data.sas';
%INCLUDE Raw_Data;
 
Thank you very much!

So if you were to run a bunch of saved programs that have similar names, except, say, at the end where the suffixes are 0 to 5, could you do something like the following?

%macro runall;
%do i = 0 %to 5;
filename raw_data&i 'T:\Robbie\Data&i..sas';
%include raw_data&i;
%end;
%mend;

%runall;

~~CW~~
 
riskassure,
Yes you can do it that way. Why not skip the filename statement and use the physical path to the file in the %inc statement.
Code:
%macro runall;
 %do i = 0 %to 5;
  %inc "T:\Robbie\Data&i..sas";
 %end;
%mend runall;

%runall;

You may have to 'clean' macro vars between programs. You should make sure that the programs do not reuse the earlier program's data sets.

Klaz
 
Many thanks! I am always looking for the shortest code possible.



~~CW~~
 
I have a sas program with this code to run a series of programs. Seems to do ok and easy to manage.




options source2;
%INCLUDE "q:\prog\yourprogram1.sas" ;
run;
proc datasets lib = work kill;run;

%INCLUDE "q:\prog\yourprogram2.sas" ;
run;
proc datasets lib = work kill;run;
 
DJE,
While you wipe the work library, you don't do any cleanup on macro vars. The work libref is not the only place that temp vars are created. This can be done using the %semdel macro statement. See help.
Also why do you put RUN between %inc statements? I remember doing that because one of the include files may be missing the last run statement, is that your reason? You could use QUIT too.
Klaz
 
Klaz -

Good point about the macros not being cleared. Most of the programs i am using rarely use macro variables. I may have to modify if new programs use macros more. As for the run statement , I dont recall any specific reason that it was added. I most likely had it initially and saw no problems, so continued.

dje
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top