|
Macros for SAS Application Developers
https://github.com/sasjs/core |
Executes a SAS Viya Job. More...
Go to the source code of this file.
Triggers a SAS Viya Job, with optional URL parameters, using the JES web app.
First, compile the macros:
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas"; %inc mc;
Then, execute the job!
%mv_jobexecute(path=/Public/folder ,name=somejob )
Example with parameters:
%mv_jobexecute(path=/Public/folder
,name=somejob
,paramstring=%str("macvarname":"macvarvalue","answer":42)
)
| [in] | access_token_var= | The global macro variable to contain the access token |
| [in] | grant_type= | valid values:
|
| [in] | path= | The SAS Drive path to the job being executed |
| [in] | name= | The name of the job to execute |
| [in] | paramstring= | A JSON fragment with name:value pairs, eg: "name":"value" or "name":"value","name2":42. This will need to be wrapped in str()`. |
| [in] | contextName= | Context name with which to run the job. Default = SAS Job Execution compute context |
| [in] | mdebug= | set to 1 to enable DEBUG messages |
| [out] | outds= | (work.mv_jobexecute) The output dataset containing links |
**/
macro mv_jobexecute(path=0 ,name=0 ,contextName=SAS Job Execution compute context ,access_token_var=ACCESS_TOKEN ,grant_type=sas_services ,paramstring=0 ,outds=work.mv_jobexecute ,mdebug=0 ); local dbg; if &mdebug=1 then do; put &sysmacroname entry vars:; put local; end; else let dbg=*;
local oauth_bearer; if &grant_type=detect then do; if symexist(&access_token_var) then let grant_type=authorization_code; else let grant_type=sas_services; end; if &grant_type=sas_services then do; let oauth_bearer=oauth_bearer=sas_services; let &access_token_var=; end;
mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password and &grant_type ne sas_services ) ,mac=&sysmacroname ,msg=str(Invalid value for grant_type: &grant_type) )
mp_abort(iftrue=("&path"="0") ,mac=&sysmacroname ,msg=str(Path not provided) ) mp_abort(iftrue=("&name"="0") ,mac=&sysmacroname ,msg=str(Job Name not provided) )
options noquotelenmax;
local base_uri; /* location of rest apis
Definition in file mv_jobexecute.sas.