Hi all,
I have some 5 programs ,say for eg: pgm1.sas, pgm2.sas, pgm3.sas. etc which i am saving in the same location. let it be D:\Path.
Is there any way to use a single %include statement to run all this programs at once?
Please help me for this.
Maybe this is doing the trick:
%let path=c:\temp;
filename sasfiles "&path";
data files;
did=DOPEN("sasfiles");
do i=1 to DNUM(did);
name=dread(did,i);
ext=SUBSTR(name,INDEX(name,".")+1);
path="&path\" ||name ;
if UPCASE(ext)="SAS" then do;
output;
call execute ("%include '"|| path || "';");
*put name= ext=;
end;
end;
run;
With "at once" do you mean "in parallel"?
I mean simply to run all 5 pgms parellel or one after other to get the 5 outputs.
Hello,
Something like this ?
filename a ("c:/temp/a.sas" "c:/temp/b.sas");
%include a;
If what you're asking for here is not just a "dumed-down" version of your real problem then just having five %include statements is by far the easiest and easiest to maintain option.
If the real problem you want to solve is of higher complexity then please share.
You can use one %INCLUDE statement by specifying the "aggregate storage location" (in this case, a directory) first:
filename progdir "D:\Path";
%include progdir(pgm1,pgm2,pgm3,pgm4,pgm5);
Note that this will run the included codes in succession.
If you want to run several SAS programs simultaneously, you need to run several SAS sessions in parallel.
Thanks for the suggestion. but in future if i add more programs how can i dynamically add those without entering in %include statement.
Can you please suggest some macros?
How do you add your programs? If you simply put them into a specific directory, and all programs in that directory need to be run, then @MCoopmans's code will do the trick.
@AKHILA wrote:
Thanks for the suggestion. but in future if i add more programs how can i dynamically add those without entering in %include statement.
Can you please suggest some macros?
Maybe this is doing the trick:
%let path=c:\temp;
filename sasfiles "&path";
data files;
did=DOPEN("sasfiles");
do i=1 to DNUM(did);
name=dread(did,i);
ext=SUBSTR(name,INDEX(name,".")+1);
path="&path\" ||name ;
if UPCASE(ext)="SAS" then do;
output;
call execute ("%include '"|| path || "';");
*put name= ext=;
end;
end;
run;
Does the order the programs are run make a difference? Or will any order work?
any order is fine
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.