Hi,
I have 100+ different reports that create some sort of output.
I am looking for a way to run multiple reports as per demand (not as per schedule through EG scheduler) through a single SAS program (maybe, by selecting report paths or similar).
just to give you some background, our users might show up and would like us to run reports (anywhere between 5 to 20) immediately and in that case I would have to open each and everyone and without any modifications would have to just press run command. that consumes a lot of time.
please advise
How are your jobs designed?
Is each report it's own eg project, it's own program?
If each is it's own SAS program put them in a SAS file with %include() and only run the ones as necessary.
If you want to be complicated you could create a file or macro that allows you to select this and then run as desired, usually if it's user driven, I'll add all reports to an excel sheet and then there's a yes/no flag they need to check - all are set at a default to no.
Once they've selected their reports you can use that as an input to your process to automate the whole thing. This is what I'd do but I'm not in a server environment with automated tools for scheduling and such.
Also, look into Ordered Lists in EG to run tasks. http://support.sas.com/kb/26/177.html
Reeza,
every report is it's own project. I was thing you may suggest something like this
Run
c:\temp\proj1.sas;
c:\temp\proj2.sas;
c:\temp\proj3.sas;
please advise
Thanks again
One way to do this is to set up a controlling program that runs all of the required reports. Here is how you could automate your report selections from a controlling program. Just change the list (Run_Pgm_List) at the top:
%let Run_Pgm_List = proj1*proj2*proj3;
%let app_saspgm_dir = C:\temp;
data _null_;
length Run_Pgm_List $ 1024;
Run_Pgm_List = symget('Run_Pgm_List');
pgm_count = countw(Run_Pgm_List, '*');
if pgm_count ge 1 then do pgm_num = 1 to pgm_count;
pgm_name = scan(Run_Pgm_List, pgm_num, '*');
call execute('%include "&app_saspgm_dir.\' !! strip(pgm_name) !! '.sas";');
end;
end;
run;
Pretty much, but it's %include to allow the programs to run.
where should I put %include
Thanks again
@tparvaiz - in my code example above the %INCLUDE statements are generated automatically. All you have to do is supply the list of programs you want run.
Excellent!
can you please advise how to run multiples files if they are in a different folder, something like this
c:\temp Folder\ File 1.sas
c:\temp Folder 2\ File 2.sas
c:\temp Folder 3\ File 3.sas
thanks again for your assistance
To run a program via %include the following is the structure:
%include 'C:\_localdata\temp.sas' \ LRECL=500;
%let Run_Pgm_List = C:\temp1\proj1*C:\temp2\proj2*C:\temp3\proj3;
data _null_;
length Run_Pgm_List $ 1024;
Run_Pgm_List = symget('Run_Pgm_List');
pgm_count = countw(Run_Pgm_List, '*');
if pgm_count ge 1 then do pgm_num = 1 to pgm_count;
pgm_name = scan(Run_Pgm_List, pgm_num, '*');
call execute('%include ' !! strip(pgm_name) !! '.sas";');
end;
end;
run;
Just add the directories to the program list.
Hi Ran the following code and got the error message
--------------Here is the code that I ran --------------------------
%let Run_Pgm_List = 'M:\ABC Documents\ABC PROJECT\Mgmt. Reports\Reports in Progress\MYREPORTS\01_cnnDT\pgm\ReportNew - Auto;
data _null_;
length Run_Pgm_List $ 1024;
Run_Pgm_List = symget('Run_Pgm_List');
pgm_count = countw(Run_Pgm_List, '*');
if pgm_count ge 1 then do pgm_num = 1 to pgm_count;
pgm_name = scan(Run_Pgm_List, pgm_num, '*');
call execute('%include ' !! strip(pgm_name) !! '.sas";');
end;
end;
run;
-----------------------Here is the log -------------------------
27 data _null_;
28 length Run_Pgm_List $ 1024;
29 Run_Pgm_List = symget('Run_Pgm_List');
30 pgm_count = countw(Run_Pgm_List, '*');
31 if pgm_count ge 1 then do pgm_num = 1 to pgm_count;
32 pgm_name = scan(Run_Pgm_List, pgm_num, '*');
33 call execute('%include ' !! strip(pgm_name) !! '.sas";');
34 end;
35 end;
---
161
ERROR 161-185: No matching DO/SELECT statement.
36 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Sorry I accidently deleted a double quote. This should work better. Also don't put quotes into the Run_Pgm_List as in your version.
%let Run_Pgm_List = C:\temp1\proj1*C:\temp2\proj2*C:\temp3\proj3;
data _null_;
length Run_Pgm_List $ 1024;
Run_Pgm_List = symget('Run_Pgm_List');
pgm_count = countw(Run_Pgm_List, '*');
if pgm_count ge 1 then do pgm_num = 1 to pgm_count;
pgm_name = scan(Run_Pgm_List, pgm_num, '*');
call execute('%include "' !! strip(pgm_name) !! '.sas";');
end;
end;
run;
still getting an error message
------------------code used -------------------
%let Run_Pgm_List = C:\Temp\test;
data _null_;
length Run_Pgm_List $ 1024;
Run_Pgm_List = symget('Run_Pgm_List');
pgm_count = countw(Run_Pgm_List, '*');
if pgm_count ge 1 then do pgm_num = 1 to pgm_count;
pgm_name = scan(Run_Pgm_List, pgm_num, '*');
call execute('%include "' !! strip(pgm_name) !! '.sas";');
end;
end;
run;
-------------------log details ---------------------------
37 %let Run_Pgm_List = C:\Temp\test;
38
39 data _null_;
40 length Run_Pgm_List $ 1024;
41 Run_Pgm_List = symget('Run_Pgm_List');
42 pgm_count = countw(Run_Pgm_List, '*');
43 if pgm_count ge 1 then do pgm_num = 1 to pgm_count;
44 pgm_name = scan(Run_Pgm_List, pgm_num, '*');
45 call execute('%include "' !! strip(pgm_name) !! '.sas";');
46 end;
47 end;
---
161
ERROR 161-185: No matching DO/SELECT statement.
48 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
FORMAT YOUR CODE.
Tip: In EG you can highlight your code, hit CTRL+I and it will format it for you.
Formatted you can very clearly see an extra end in your code.
%let Run_Pgm_List = C:\Temp\test;
data _null_;
length Run_Pgm_List $ 1024;
Run_Pgm_List = symget('Run_Pgm_List');
pgm_count = countw(Run_Pgm_List, '*');
if pgm_count ge 1 then
do pgm_num = 1 to pgm_count;
pgm_name = scan(Run_Pgm_List, pgm_num, '*');
call execute('%include "' !! strip(pgm_name) !! '.sas";');
end;
end; *<-----WHY DO YOU HAVE THIS;
run;
@Reeza - thanks for spotting this. Thats the problem when you do a quick change to working code without testing!
%let Run_Pgm_List = C:\temp1\proj1*C:\temp2\proj2*C:\temp3\proj3;
data _null_;
length Run_Pgm_List $ 1024;
Run_Pgm_List = symget('Run_Pgm_List');
pgm_count = countw(Run_Pgm_List, '*');
if pgm_count ge 1 then do pgm_num = 1 to pgm_count;
pgm_name = scan(Run_Pgm_List, pgm_num, '*');
call execute('%include "' !! strip(pgm_name) !! '.sas";');
end;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.