BookmarkSubscribeRSS Feed

Using SAS Viya Data Step Score Code in SAS 9.4

Started ‎08-24-2020 by
Modified ‎08-25-2020 by
Views 3,121

SAS Viya and SAS 9.4

SAS Viya is a cloud-enabled, in-memory analytics engine. The architectural designs of SAS Viya allow rapid processing of large data for even the most complex analytical endeavors. SAS Viya enables organizations to seamlessly integrate the entire analytics life cycle from data to discovery to deployment.

 

SAS 9.4 offers a highly available and resilient platform for traditional on-premise environments with additional support for cloud deployments. Recent releases of SAS 9.4 allow for the use of multi-core technologies for high-performance, in-database, and in-memory analytics. Several familiar products sit on SAS 9.4, such as SAS Studio 3.8, SAS Enterprise Guide, and SAS Enterprise Miner.

 

Scoring SAS Viya Models in SAS 9.4

This solution is for organizations that use both SAS 9.4 and SAS Viya. SAS Viya and SAS 9.4 can act as complements and form one analytical platform. Organizations have varying needs that require flexibility in their analytical processes. The SAS platform provides this flexibility and more, enabling organizations to develop stronger analytical capabilities. 

 

Some organizations want to make use of the model building capabilities on Viya, such as these options for hyperparameter autotuning and automated machine learning, but have built complex custom model execution frameworks on SAS 9.4. These customizations may fit their current business well and they aren't able to rebuild their custom code to fit SAS Viya's execution framework immediately. Thus, these organizations may need a solution with flexibility to work with both SAS Viya and SAS 9.4. 

 

SAS Viya and SAS 9.4 interoperate in a variety of ways. This post focuses on scoring data in SAS 9.4 using Data Step score code developed in SAS Viya. Following posts will examine methods for other model types, such as ASTORE here. The methods mentioned in this series of articles were tested using SAS Viya 3.5 and SAS 9.4M6.

 

SAS Viya Score Code

Within SAS Visual Data Mining and Machine Learning (VDMML) on SAS Viya, there are several ways to build analytical models. First, models can be built using a visual model pipelining interface called SAS Model Studio. These model pipelines consist of  data preprocessing steps, supervised model building, model postprocessing steps and more. Model pipelines are easy to use and customize. They offer strong analytical capabilities such as automated machine learning, hyperparameter autotuning, and model interpretability.

Model PipelineModel Pipeline

 

Second models can be built programmatically using languages such SAS, Python, and R. Programmatic models offer the same analytical capabilities and often allow the programmer to access additional parameters and techniques. While programming offers more power to the programmer, it often offers less ease-of-use than visual interfaces. The examples below will include models built in the visual pipeline interface as well as programmatically.

 

It is important to note prior to getting started that different types of models built in SAS Viya create either Data Step score code or Analytic Store score code. SAS 9.4 can handle both Analytic Store and Data Step models. While the process may be different for each type of score code, we can be confident that SAS 9.4 can handle it. This table shows the relationship between model type and score code. 

 

This post will focus on the Data Step score code models built in Model Studio and SAS Studio. Check out this post for ASTORE score code models!

 

Data Step Score Code from Model Studio

For the Data Step model, I used a logistic regression. The first step is to export the model for production. From the Pipeline Comparison tab in Model Studio, select the checkbox to the left of the logistic regression model, open the options menu (3 dots on right as circled), and select Download score code. This starts a downloaded for a zip file containing dmcas_scorecode. This SAS file is the body of a DATA step.

image.png

 

Next, open dmcas_scorecode in a SAS 9.4 interface. Wrap a DATA step around dmcas_scorecode  by adding the data statement, specifying the name of the scored data, and set statement, specifying the data to be scored,  at the beginning and a run statement at the end. Now when you can run the code and collect the scored data set.

image.png

 

Data Step Score Code from SAS Studio

For this model, I will also use a logistic regression. When creating your model, use the CODE statement and specify a FILE= in a location you can access. This statement will create the dmcas_scorecode, which is the body of your DATA step. Run your model and find the code in your specified location.  

 image.png

 

Now, you can open the code from a SAS 9.4 interface and add the data statement and set statement at the beginning of the code and a run statement at the end of the code, like mentioned earlier with the DATA Step Model in Model Studio.

 

Conclusion

Some organizations may need a solution with flexibility to work with both SAS Viya and SAS 9.4. The SAS platform provides this flexibility and more, enabling organizations to develop stronger analytical capabilities. Stay tuned for my next post on Analytic Store score code!

Version history
Last update:
‎08-25-2020 03:28 PM
Updated by:
Contributors

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

SAS AI and Machine Learning Courses

The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.

Get started

Article Tags