BookmarkSubscribeRSS Feed

Using SAS Viya ASTORE Score Code in SAS 9.4

Started ‎08-25-2020 by
Modified ‎12-18-2023 by
Views 3,260

Caveat: This process was developed using ASTORE models developed on SAS Viya 3.5. This process is not guaranteed to work for all ASTORE files on Viya 3.5. On Viya 4, changes in ASTORE files to improve performance have made this process incompatible. For individuals seeking to leverage ASTORE models developed in SAS Viya 4 within SAS 9.4, please try this alternative approach using the MAS publishing destination and REST APIs.”

 

SAS Viya and SAS 9.4

As I discussed in an earlier post, some organizations need flexibility to use both SAS Viya and SAS 9.4 in their analytical process. This solution is aimed at organizations that want to take models built within SAS Viya and use SAS 9.4 to execute scoring. SAS Viya and SAS 9.4 can act as complements to form one analytical platform. These two can interoperate in a variety of ways, but today we will focus on taking ASTORE Score Code from Viya to run in SAS 9.4.

 

Depending on the model algorithm, SAS Viya will create one of two score code types: Analytic Store (ASTORE) or Data Step. This handy table lists the type of score code created for each of the algorithms. This post only focuses on ASTOREs, so if you are looking for Data Step, please see my earlier post. Just like in my previous post, I will use an example from the visual pipelining tool, Model Studio, as well as an example from the SAS programming tool, SAS Studio.

 

Analytic Store Score Code from Model Studio

For the ASTORE model, I will use a random forest. 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 random forest model, open the options menu (3 dots on right as circled), and select Download score code. This downloads a zip file containing a SAS file named dmcas_epscorecode. This SAS file contains a DATA STEP that accesses an analytical store (ASTORE) that by default will be in the Models CASLIB.

SophiaRowland_0-1598382976315.png

 

Before we can use the model in SAS 9.4, we will need to download the ASTORE from Viya. You will need to find the associated analytical store in the Models CASLIB though SAS Data Explorer ("Manage Data" on the main menu). The ASTORE table will be named using an underscore followed by a string of letters and numbers. Once you find the ASTORE, promote the data into a CASLIB you can access. You can promote the ASTORE by selecting the lightening bolt in the upper corner or by selecting Load from the menu.  

SophiaRowland_1-1598382976327.png

 

Next, open "Develop SAS Code" from the Viya menu.  Use PROC ASTORE with the DOWNLOAD statement to download the ASTORE into a folder you can access.  

SophiaRowland_2-1598382976329.png

 

Finally, ensure that the dmcas_epscorecode file and the ASTORE file are in a location accessible to SAS 9.4. To score new data, use PROC ASTORE with the SCORE statement. Use the data=, store=, and epcode= options to point to the new data, the ASTORE, and the epcode.

SophiaRowland_3-1598382976348.png

 

 

Analytic Store Score Code from SAS Studio

For the SAS Studio example, I also used a Random Forest model. When creating the forest model using PROC FOREST, ensure that within the SAVESTATE statement, a rstore= is specified in a library you can access.

SophiaRowland_4-1598382976351.png

 

Unlike in Model Studio, you will need to generate the epcode file. This file can be easily generated using PROC ASTORE with the DESCRIBE statement.

SophiaRowland_5-1598382976352.png

 

This will save the epcode file to the location specified in the epcode= option. Just like in the previous example, you will need to run PROC ASTORE using the DOWNLOAD statement to download the ASTORE from SAS Viya. Now that you have the ASTORE and the epcode, you can use PROC ASTORE with the SCORE statement in SAS 9.4  just like in the previous example.

 

Conclusion

Using today’s post and my previous post, you can now take the models built on SAS Viya down into SAS 9.4 for scoring. 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.

 

Interested in learning more? Check out these related posts:

Version history
Last update:
‎12-18-2023 08:54 AM
Updated by:
Contributors

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags