|
Macros for SAS Application Developers
https://github.com/sasjs/core |
Extract the result from a completed SAS Viya Job. More...
Go to the source code of this file.
Extracts result from a Viya job and writes it out to a fileref and/or a JSON-engine library.
To query the job, you need the URI. Sample code for achieving this is provided below.
First, compile the macros:
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas"; %inc mc;
Next, create a job (in this case, a web service):
filename ft15f001 temp;
parmcards4;
data test;
rand=ranuni(0)*1000;
do x=1 to rand;
y=rand*4;
output;
end;
run;
proc sort data=&syslast
by descending y;
run;
%webout(OPEN)
%webout(OBJ, test)
%webout(CLOSE)
;;;;
%mv_createwebservice(path=/Public/temp,name=demo)
Execute it:
%mv_jobexecute(path=/Public/temp ,name=demo ,outds=work.info )
Wait for it to finish, and grab the uri:
data _null_;
set work.info;
if method='GET' and rel='self';
call symputx('uri',uri);
run;
Finally, fetch the result (In this case, WEBOUT):
%mv_getjobresult(uri=&uri,result=WEBOUT_JSON,outref=myweb,outlib=myweblib)
| [in] | access_token_var= | The global macro variable containing the access token |
| [in] | mdebug= | set to 1 to enable DEBUG messages |
| [in] | grant_type= | valid values:
|
| [in] | uri= | The uri of the running job for which to fetch the status, in the format /jobExecution/jobs/$UUID (unquoted). |
| [out] | result= | (WEBOUT_JSON) The result type to capture. Resolves to "_[column name]" from the results table when parsed with the JSON libname engine. Example values:
|
| [out] | outref= | (0) The output fileref to which to write the results |
| [out] | outlib= | (0) The output library to which to assign the results (assumes the data is in JSON format) |
Definition in file mv_getjobresult.sas.