Desktop productivity for business analysts and programmers

Scheduling multiple jobs

Reply
Frequent Contributor
Posts: 131

Scheduling multiple jobs

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

 

Super User
Posts: 19,038

Re: Scheduling multiple jobs

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

Frequent Contributor
Posts: 131

Re: Scheduling multiple jobs

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

Super User
Posts: 3,233

Re: Scheduling multiple jobs

[ Edited ]

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;

 

Super User
Posts: 19,038

Re: Scheduling multiple jobs

Pretty much, but it's %include to allow the programs to run. 

 

 

Frequent Contributor
Posts: 131

Re: Scheduling multiple jobs

where should I put %include

 

Thanks again

Super User
Posts: 3,233

Re: Scheduling multiple jobs

@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.

Frequent Contributor
Posts: 131

Re: Scheduling multiple jobs

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

Super User
Posts: 19,038

Re: Scheduling multiple jobs

To run a program via %include the following is the structure:

 

%include 'C:\_localdata\temp.sas' \ LRECL=500;
Super User
Posts: 3,233

Re: Scheduling multiple jobs

[ Edited ]
%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.

Frequent Contributor
Posts: 131

Re: Scheduling multiple jobs

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

 

 

Super User
Posts: 3,233

Re: Scheduling multiple jobs

[ Edited ]

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;
Frequent Contributor
Posts: 131

Re: Scheduling multiple jobs

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

Super User
Posts: 19,038

Re: Scheduling multiple jobs

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;
Super User
Posts: 3,233

Re: Scheduling multiple jobs

[ Edited ]

@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;
Ask a Question
Discussion stats
  • 16 replies
  • 238 views
  • 1 like
  • 3 in conversation