Think about digital transformation. It’s a constant and inevitable. You have a lot of code that you developed producing great calculations, statistics and graphs. So, what is the best way to present all of your work for other to consume? Do you still need to login and run your code every time? What if you automate it with APIs or jobs?
If you are a software engineer, you could easily create an application that would automate your code, but not everyone has that skill. Luckily, SAS has created functionality that is very friendly for business analysts to create automation and code execution from a HTML form. It is called SAS Job Execution.
If you have used SAS in the past, you probably have come across something called Stored Process on SAS 9. This allows you to export your code and create a web page allowing you run code through an HTML page. SAS Job Execution on SAS Viya presents a similar idea, with a couple of improvements.
SAS Job Execution is a web application that comes with SAS Viya. It allows users to create SAS code and tie it to an HTML form that can then pass parameters to the job, resulting in an output. This output takes one of many forms. In this article we explore the SAS Output page with plots and tables.
One of the good things about this web application is when you create SAS Code in a Job Execution project, it automatically becomes an API to which you pass parameters.
If you are curious on how SAS Job Execution works behind the scenes, consider looking at the overview of the SAS Job Execution Web Application page.
Now that we understand what it is, let's go through our first SAS Job Execution app. We will follow these steps:
For this example, think about a loan company that needs to calculate the likelihood of default on loans. The bank loan representative is responsible for aquiring and entering potential customer data into an application. The application, in turn, returns the default probability of default right away. The decision variables used are:
Our main asset in this project will be the pre-trained model generated by a data scientist. This file - ASTORE - represents the model binary. We will use this model to score the input data, and then, will generate a couple of plots to show the applicant how their inputs compare with the historical data - the HMEQ table.
You can find all the assets in this Github repository.
Name |
Default value |
Field type |
Required |
p_loan |
|
Numeric |
Yes |
p_mortdue |
|
Numeric |
Yes |
p_value |
|
Numeric |
Yes |
p_yoj |
|
Numeric |
Yes |
P_reason |
|
Character |
Yes |
P_job |
|
Character |
Yes |
_action |
Form |
Character |
Yes |
_CASHOST |
<your SAS server> |
Character |
Yes |
<!-- Change the path to match your job execution file. -->
<input type="hidden" name="_program" value="/Users/ludepa/JES/scoringJob">
Note: the first time I submitted the form, I received an error. Referencing to the logs (the gear icon on the Job Execution screen) alerted me of a connection error. It turns out in my multi-node environment, I had to provide the fully qualified URL for the CAS controller in the _CASHOST_ parameter. This will vary from deployment to deployment.
As you can see in the response, this application is approved. The generated SGPLOTs represent how the scored data compares against the historical data used to train this model. Let’s take the first graph as an example.
The goal of these graphs is to show to the analyst how the request compares against the population this model knows. It helps as a guide providing feedback for the data scientists or to explain to the customer why they might have been denied a loan.
The video below outlines the step-by-step process of the example explained in this article. I added some comments on the video so you can follow along.
As we saw in this article, you can take your code and wrap it around an API using the SAS Job Execution. You can pass parameters to your code through macro variables and create HTML forms that connects to your code. Job Execution enables you to call SAS code from other applications or use the generated form to embed it into applications. This is an easy and intuitive way to organize your codes as well as share them.
In the next article, we will learn other features from SAS Job Execution - the SAS Job Flow Scheduler, where we will schedule a job to run using the scheduler.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.