Production Ready Macros for SAS Application Developers File Reference

Takes a dataset of running jobs and waits for ANY or ALL of them to complete. More...

Go to the source code of this file.

Detailed Description

Will poll /jobs/{jobId}/state at set intervals until ANY or ALL jobs are completed. Completion is determined by reference to the returned state, as per the following table:

state Wait? Notes
idle yes We assume processing will continue. Beware of idle sessions with no code submitted!
pending yes Job is preparing to run
running yes Job is running
canceled no Job was cancelled
completed no Job finished - does not mean it was successful. Check stateDetails
failed no Job failed to execute, could be a problem when calling the apis


First, compile the macros:

filename mc url
%inc mc;

Next, create a job (in this case, as a web service):

filename ft15f001 temp;
  data ;
    do x=1 to rand;

Then, execute the job,multiple times, and wait for them all to finish:


  set work.ds1 work.ds2 work.ds3 work.ds4;
  where method='GET' and rel='state';


Delete the job:

[in]access_token_var=The global macro variable to contain the access token
[in]grant_type=valid values:
- password
- authorization_code
- detect - will check if access_token exists, if not will use sas_services if
  a SASStudioV session else authorization_code.  Default option.
- sas_services - will use oauth_bearer=sas_services
[in]action=EitherALL (to wait for every job) or ANY (if one job completes, processing will continue). Default=ALL.
[in]inds=The input dataset containing the list of job uris, in the following format: /jobExecution/jobs/&JOBID./state and the corresponding job name. The uri should be in a uri variable, and the job path/name should be in a _program variable.
[out]outds=The output dataset containing the list of states by job (default=work.mv_jobexecute)
VIYA V.03.04
Allan Bowe, source:


Definition in file