/** @file @brief Extract the status from a running SAS Viya job @details Extracts the status from a running job and appends it to an output dataset with the following structure: | uri | state | timestamp | |---------------------------------------------------------------|---------|--------------------| | /jobExecution/jobs/5cebd840-2063-42c1-be0c-421ec3e1c175/state | running | 15JAN2021:12:35:08 | To query the running job, you need the URI. Sample code for achieving this is provided below. ## Example First, compile the macros: filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas"; %inc mc; Next, create a long running job (in this case, a web service): filename ft15f001 temp; parmcards4; data ; rand=ranuni(0)*1000; do x=1 to rand; y=rand*4; output; end; run; data _null_; call sleep(5,1); run; ;;;; %mv_createwebservice(path=/Public/temp,name=demo) Execute it, grab the uri, and finally, check the job status: %mv_jobexecute(path=/Public/temp ,name=demo ,outds=work.info ) data _null_; set work.info; if method='GET' and rel='state'; call symputx('uri',uri); run; %mv_getjobstate(uri=&uri,outds=results) You can run this macro as part of a loop to await the final 'completed' status. The full list of status values is: @li idle @li pending @li running @li canceled @li completed @li failed If you have one or more jobs that you'd like to wait for completion you can also use the [mv_jobwaitfor](/mv__jobwaitfor_8sas.html) macro. @param [in] access_token_var= (ACCESS_TOKEN) The global macro variable to contain the access token @param [in] grant_type= valid values: @li password @li authorization_code @li detect - will check if access_token exists, if not will use sas_services if a SASStudioV session else authorization_code. @li sas_services - will use oauth_bearer=sas_services. @param [in] uri= The uri of the running job for which to fetch the status, in the format `/jobExecution/jobs/$UUID/state` (unquoted). @param [out] outds= The output dataset in which to APPEND the status. Three fields are appended: `CHECK_TM`, `URI` and `STATE`. If the dataset does not exist, it is created. @version VIYA V.03.04 @author Allan Bowe, source: https://github.com/sasjs/core