Building on the article
I want to pre-filter a table and use this resulting table in the XML prompts
<Metadata>
<DataSources>
carried out by the second job.
The first job works well, but the second job does not create the form thus fails to do any meaningful.
* Make the utility macros available;
%jesutil()
* Declare the program variables;
%global make
type
J1JOBID
J2JOBID
QUERY_VALUE
SERVICESBASEURL;
* Initialize the program variables;
%let DSNAME=class;
%let SERVICESBASEURL=%sysfunc(getoption(servicesbaseurl));
*;
* Specify that the J1 job is executed in the background. Progress
* can be monitored using the SAS Job Execution Web Application
* Jobs page (/SASJobExecution/jobs).
*;
%let QUERY_VALUE=FORM('_action'='background' '_program'='/Users/cordear1/My Folder/jobs/test sequential run v1' 'make'="&make" 'type'="&type");
/* %let QUERY_VALUE=FORM('_action'='background' '_program'='/Users/cordear1/My Folder/jobs/test sequential run v1' 'sleep'='5' 'make'="&make" 'type'="&type"); */
/* %let QUERY_VALUE=FORM('_action'='form,prompts,execute' '_program'='/Users/cordear1/My Folder/jobs/test sequential run v2'); */
*;
* The macro does not wait for the job to finish execution because _action=background is
* specified. You use the value of the J1JOBID macro variable with the
* %JOBEXEC_WAITFOR macro to wait for the job to complete before executing further
* statements.
*;
%jobexec_run(baseurl=&SERVICESBASEURL,
in=&QUERY_VALUE,
jobid_varname=J1JOBID);
%if (&_JOBRUN_RC eq 0) %then %do;
%put NOTE: You can view the job execution object at /jobExecution/jobs/&J1JOBID;
%end;
%else %do;
%put ERROR: Problem running the job. &=_JOBRUN_RC &=_STATUS_MESSAGE;
%end;
* Wait for the J1 job to finish before executing more statements;
%jobexec_waitfor(baseurl=&SERVICESBASEURL,
jobid=&J1JOBID)
%if (&_JOBRUN_RC eq 0) %then %do;
%put NOTE: Job finished executing. Final job state is "&_JOBRUN_STATE".;
%end;
%else %do;
%put ERROR: Problem waiting for the job. &=_JOBRUN_RC &=_STATUS_MESSAGE &=_JOBRUN_ERRMSG;
%end;
* Execute the second job;
/* %let QUERY_VALUE=FORM('_program'='/Users/cordear1/My Folder/jobs/test sequential run v2'); */
/* %let QUERY_VALUE=FORM('_action'='json' '_program'='/Users/cordear1/My Folder/jobs/test sequential run v2' 'sleep'='5' 'make'="&make" 'type'="&type"); */
%let QUERY_VALUE=FORM('_action'='form,prompts,execute' '_OUTPUT_TYPE'='html' '_program'='/Users/cordear1/My Folder/jobs/test sequential run v2' 'sleep'='5' 'make'="&make" 'type'="&type");%let QUERY_VALUE=FORM('_action'='json' '_program'='/Users/cordear1/My Folder/jobs/test sequential run v2' 'sleep'='5' 'make'="&make" 'type'="&type");
*;
* The macro waits for the job to finish execution because _action=background is not
* specified.
*;
%jobexec_run(baseurl=&SERVICESBASEURL,
in=&QUERY_VALUE,
jobid_varname=J2JOBID);
%if (&_JOBRUN_RC eq 0) %then %do;
%put NOTE: You can view the job execution object at /jobExecution/jobs/&J2JOBID;
%put NOTE: You can view the job output at /SASJobExecution/?_jobexec=/jobExecution/jobs/&J2JOBID;
%end;
%else %do;
%put ERROR: Problem running the job. &=_JOBRUN_RC &=_STATUS_MESSAGE;
%end;
I suspect that I'm missing the correct definition of the _action or _output_type parameter in the following line.
%let QUERY_VALUE=FORM('_action'='form,prompts,execute' '_OUTPUT_TYPE'='html' '_program'='/Users/cordear1/My Folder/jobs/test sequential run v2' 'sleep'='5' 'make'="&make" 'type'="&type");%let QUERY_VALUE=FORM('_action'='json' '_program'='/Users/cordear1/My Folder/jobs/test sequential run v2' 'sleep'='5' 'make'="&make" 'type'="&type");
One thing I think for the error message:
"There is no handler defined for the path /SASJobExecution/jobs..."
the URL should be /jobExecution/jobs instead of /SASJobExecution/
Hello @acordes, are you good?
So, the problem is that you're overwriting the QUERY_VALUE macro variable twice on the same line:
%let QUERY_VALUE=FORM(...); %let QUERY_VALUE=FORM(...);
Only the second assignment actually takes effect. So, if you intended to run the job with both settings (HTML and JSON), only the last one (_action='json') is being used.
You should:
You're overwriting the macro variable, so only the last value is used. Split them up, and run each job separately with its own macro assignment.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.