Data is retrieved via an authenticated HTTP request to the SAS Workload Orchestrator REST API. The body of the response, in JSON format, is then read and processed as a SAS data source.
1 Code Block
Macro Variables & FILENAME Statements
Explanation : This block initializes macro variables for authentication (`username`, `pw`) and the base URL (`baseURL`) of the SAS Workload Orchestrator API. It also defines two temporary filerefs, `body` and `headout`, to store the HTTP response body and headers respectively.
Explanation : `PROC HTTP` is used to send a GET request to the SAS Workload Orchestrator jobs API. The URL is dynamically constructed with the `baseURL` macro variable and a `state=ALL` parameter to retrieve all non-archived jobs. Basic authentication is handled via `webusername` and `webpassword`. The response body is saved to the `body` fileref and headers to `headout`. An `Accept` header is specified for a specific API JSON format.
Explanation : The first `libname jobinfo;` deallocates any existing libname with this name, ensuring a clean reset. The second `libname jobinfo json fileref=body;` creates a SAS library `jobinfo` by interpreting the JSON content of the `body` fileref (which contains the API response) as SAS tables. This makes the JSON data accessible via SAS tables.
Explanation : This `PROC SQL` procedure creates a new `jobs` table in the `WORK` library. It performs a complex join between several virtual tables generated by the `LIBNAME JSON` (`jobinfo.jobs`, `jobinfo.jobs_processinginfo`, `jobinfo.jobs_request`) using the `ordinal_jobs` columns. The objective is to consolidate relevant job information (ID, state, queue, times, host, exit code, job name, user, command) into a single view ordered by job ID.
Copied!
proc sql;
create table jobs as
select
a.id,
b.state, b.queue, b.submitTime, b.startTime, b.endTime,
b.processId, b.executionHost, b.exitCode,
c.name, c.user, c.cmd from
jobinfo.jobs a,
jobinfo.jobs_processinginfo b,
jobinfo.jobs_request c
where a.ordinal_jobs = b.ordinal_jobs and
b.ordinal_jobs = c.ordinal_jobs
order by a.id;
quit;
Explanation : The `PROC PRINT` procedure displays the content of the `work.jobs` table that was previously created, thus presenting the consolidated information on SAS Workload Orchestrator jobs.
Copied!
proc print data=work.jobs; run;
1
PROC PRINTDATA=work.jobs; RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Author: Greg Wootton Date: 02JAN2019
« Programmatic access to SAS Workload Orchestrator (SWO) data is essential for administrators who need to automate grid monitoring or create custom performance reports. This script demonstrates a robust method for transforming complex system metrics into actionable datasets within your SAS session. »
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.