BookmarkSubscribeRSS Feed
Ullsokk
Pyrite | Level 9

I have tried using score code from SAS viya, both downloaded from model studios pipeline comparison, and retrieved through the api. But I can't find any good explanation of how to get the code running. The downloaded code starts with

 

 

data sasep.out;
   dcl package score _DMRUA0HQGLBC1HBUQ4T9AK();
   dcl double "P_target_flg1" having label n'Predicted: target_flg=1';
  

But I get the following error messages:

ERROR: DATA STEP Component Object failure.  Aborted during the COMPILATION phase.
ERROR 565-185: PACKAGE is not a known class name.

For the score code from the api, the code starts with

package MS_09368ff81a7b41aea9fbac8bd_15SEP2020120014413 / overwrite=yes;
   dcl package score _JMW1HUQBK0CMF01WMVD();
   dcl double "P_target_flg1" having label n'Predicted: target_flg=1';

Both seem to be some ds2 code, but the first code does not start with a ds2 step. And the latter does not work with either ds2 or a data step. I have also tired inlcuding them as sas files in a data step with no luck. How is this code supposed to be used?

 

11 REPLIES 11
SophiaRowland
SAS Super FREQ

The type of score code will vary based on the type of model. This link explains which model type will result in which score code type. I have two articles for scoring in 9.4, but you should be able to re-use some of this process for SAS Viya.  For Data Step models, you can consult this article.  For ASTORE models, you can consult this article.  Does this help? 

Ullsokk
Pyrite | Level 9

So to deploy a model to production, if it is a gradient boosting, which would be an astore - I have to:

  • download the .sas score code to my physical pc
  • find out what the astore file is named in this code
  • Go to data manager and load the correct random filename
  • promote the file using the lightning button
  • go to sas studio
  • write a proc astore download to downlaod the already loaded sashdat file to my pc
  • write a final proc ascore score statement referring to two different physical files on my pc, not files in VIYA

I am confused to put it mildly. 

 

SophiaRowland
SAS Super FREQ

I am sorry for the confusion. The previous documentation was written more for scoring on 9.4. Keeping things on Viya should be a bit simpler, but will follow a similar process. Are you looking for a way to score data using a model built in model studio or is scoring data in SAS Studio on Viya the requirement? 

 

If you just need a way to score data, you can use the Score Data node in Model Studio. 

 

This documentation goes over using score code on Viya a bit better. If you need to score within SAS Studio on Viya, you will need to: 

  1. Download the score code from Model Studio. 
  2. Within the score code file, you can find the name of the ASTORE within the comments at the top. I found the corresponding ASTORE in my Models CASLIB. I promoted it into memory. 
  3. Upload the score code into a location accessible from SAS Studio, which for me was on the SAS Server. I selected a folder on SAS Server (visible from the Explorer menu in SAS Studio), right clicked, and selected upload. 
  4. Load the data to be scored into SAS Studio. 
  5. Run PROC ASTORE with score statement, pointing rstore to the promoted table from step 2 and epcode to the file from step 3, like so: 
    proc astore;
        score data=your_cas_lib.data_to_score
              rstore=Models.astore_table
              epcode='/home/my_folder/dmcas_epscorecode.sas'
              out=your_cas_lib.scored_data;
    quit;
    Does this help? 
Ullsokk
Pyrite | Level 9

Why doesnt the proc just require the .sas scorecode? The astore is referenced in the file, so the program could just read the string, load the astore and promote it, without all the manual overhead right? 

 

I want to set up scoring in production inside VIYA using the job scheduler. So I need to be able to retrieve all the required details to score data from the VIYA API (not to be confused with the API score code you can manually download). I only get what seems to be a epscorecode, but it does not look exactly like the score code I get from manually downloading the score code, as the manually downloaded starts with 

 

/*
 * This score code file references one or more analytic stores that are located in the caslib "Models".
 * This score code file references the following analytic-store tables:
 *   _96SJQFBWWOK4EGEAM4HYEDMKS_ast
 */
data sasep.out;
   dcl package score _96SJQFBWWOK4EGEAM4HYEDMKS();

and the one from the API looks like this:

 

package MS_09368ff81a7b41aea9fbac8bdeea6aec_15SEP2020120014413 / overwrite=yes;
   dcl package score _JMW1HUQBK0CMF01WMVDI39WS();

Without the data step and starting with just package, not dcl package. Which I guess could be a bug? I suppose it should also start with dcl?

 

So I can get what seems to be the .sas epcode from the API. Inside that file, there is a method() part. So I guess I have to parse the file, find the string to find the astore\.sashdat, load the dataset, promote it, save the file two files, then use the two in a proc astore? And correct the missing dcl in the start of the file I guess.

 

I have to set this up to run daily scoring, so I can't rely on manually reading and loading and promoting tables. But I can't quite believe how convoluted this is compared to using the old score codes, or scoring in any other environment for that sake.  

SophiaRowland
SAS Super FREQ

Using the one you manually downloaded, you can use proc astore using the astore name from the epcode file, the single epcode file, and the data to be scored. As for setting this up for daily scoring, the only things that will change is the data, correct? Until you change your model, the epcode and astore will remain the same. 

 

Ullsokk
Pyrite | Level 9

Can you please give an example of how the file reference should look for a file store in my folder in Viya? I have tried the following, all with the error "external file does not exist"

 

/*            epcode= "</U/myuser/>test score code DMRUA.sas"   */
/*            epcode= "</Users/myuser/>test score code DMRUA.sas"   */
/*            epcode= "/Users/myuser/test score code DMRUA.sas"    */
/*            epcode= "/U/myuser/test score code DMRUA.sas"    */
/*            epcode= "/u/myuser/test score code DMRUA.sas"    */
              epcode= "/users/myuser/test score code DMRUA.sas"   

I can reference a file in myfolder in VIYA right? I don't have to actually store a local file?

 

 

Hi @Ullsokk and @SophiaRowland 

 

I'm currently experiencing the same 'external file does not exist' error. I've tried a few variations for the file reference for epcode without any luck. Please can you advise what the correct format is for the file reference?

 

Thanks,

 

Ashley

SophiaRowland
SAS Super FREQ

Hi Ashley, On SAS Studio do you have a server file system accessible where you can place the epcode file? From the Explore Menu, it has a little icon that looks like a server box. (https://go.documentation.sas.com/?activeCdc=webeditorcdc&cdcId=sasstudiocdc&cdcVersion=5.2&docsetId=...

Hi Sophia,

 

Thanks for your reply. I recently opened a track with SAS Support and we've managed to resolve the issue that I was having. It turns out that removing the 'epcode' line of code in proc astore worked for me as that line of code is optional. I've been able to successfully make predictions on new data after removing this line of code (and keeping everything else the same).

 

Thanks,

 

Ashley

Ullsokk
Pyrite | Level 9

At second glance, those articles are on how to score VIYA models in 9.4. I am just trying to score the data in VIYA. Using code from the VIYA API 

SophiaRowland
SAS Super FREQ

Yes, the first set of articles are for 9.4, but the links in the latest reply are for Viya. Are you trying to use the epcode or the API? 

SAS Innovate 2025: Register Now

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!

Discussion stats
  • 11 replies
  • 5632 views
  • 2 likes
  • 3 in conversation