BookmarkSubscribeRSS Feed

Using SAS Viya ASTORE Score Code in SAS 9.4

Started ‎08-25-2020 by
Modified ‎08-25-2020 by
Views 2,893

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.



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.  



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.  



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.




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.



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.



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.



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:
‎08-25-2020 03:26 PM
Updated by:



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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