|
Macros for SAS Application Developers
https://github.com/sasjs/core |
Execute a series of job flows. More...
Go to the source code of this file.
Very (very) simple flow manager. Jobs execute in sequential waves, all previous waves must finish successfully.
The input table is formed as per below. Each observation represents one job. Each variable is converted into a macro variable with the same name.
SAS Job Execution compute context.Any additional variables provided in this table are converted into macro variables and passed into the relevant job.
| _PROGRAM | FLOW_ID (optional) | _CONTEXTNAME (optional) |
|---|---|---|
| /Public/jobs/somejob1 | 0 | SAS Job Execution compute context |
| /Public/jobs/somejob2 | 0 | SAS Job Execution compute context |

To avoid hammering the box with many hits in rapid succession, a one second pause is made between every request.
First, compile the macros:
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas"; %inc mc;
Next, create some jobs (in this case, as web services):
filename ft15f001 temp;
parmcards4;
%put this is job: &_program;
%put this was run in flow &flow_id;
data ;
rand=ranuni(0)*¯ovar1;
do x=1 to rand;
y=rand*¯ovar2;
if y=100 then abort;
output;
end;
run;
;;;;
%mv_createwebservice(path=/Public/temp,name=demo1)
%mv_createwebservice(path=/Public/temp,name=demo2)
Prepare an input table with 60 executions:
data work.inputjobs;
_contextName='SAS Job Execution compute context';
do flow_id=1 to 3;
do i=1 to 20;
_program='/Public/temp/demo1';
macrovar1=10*i;
macrovar2=4*i;
output;
i+1;
_program='/Public/temp/demo2';
macrovar1=40*i;
macrovar2=44*i;
output;
end;
end;
run;
Trigger the flow
%mv_jobflow(inds=work.inputjobs ,maxconcurrency=4 ,outds=work.results ,outref=myjoblog ) data _null_; infile myjoblog; input; put _infile_; run;
| [in] | access_token_var= | The global macro variable to contain the access token |
| [in] | grant_type= | valid values:
|
| [in] | inds= | The input dataset containing a list of jobs and parameters |
| [in] | maxconcurrency= | The max number of parallel jobs to run. Default=8. |
| [in] | raise_err=0 | Set to 1 to raise SYSCC when a job does not complete succcessfully |
| [in] | mdebug= | set to 1 to enable DEBUG messages |
| [out] | outds= | The output dataset containing the results |
| [out] | outref= | The output fileref to which to append the log file(s). |
Definition in file mv_jobflow.sas.