BookmarkSubscribeRSS Feed
acordes
Rhodochrosite | Level 12

Right after supervised learning nodes in Model Studio VDMML on SAS Viya 4, I place a sas code node to score a table with the learned scoring code. Meanwhile I can use the macro variable for referencing the astore after SVM and Gradient Boosting for example, I cannot figure out how to so for models that do not produce astore like logistic regression.

I can only achieve the scoring operation if I hard-cop the scoring code from the prior node and paste it into the data step. 

 

One of my many attempts is this: 

 

data grid_scored;
    set grid;
    %include "&dm_file_scorecode.";
run;

pic6.pngpic5.pngpic4.pngpic3.pngpic2.pngpic1.png 

4 REPLIES 4
sbxkoenk
SAS Super FREQ

A logistic regression in Model Studio creates DATA step score code indeed (and not an Analytic store).

See here for a table Node Name + Type of Score Code.

https://go.documentation.sas.com/doc/en/vdmmlcdc/v_031/vdmmladvug/p0avxptqga2me0n0z81v01ky6t9o.htm

 

But the data step score code from a preceding logistic regression will not be the content of the &dm_file_scorecode macro variable in a subsequent code node.

 

Model Studio will use &dm_file_scorecode to get the score code for your code node.

This happens if you dynamically (and data-driven) create score code with the SAS code node in Model Studio. You should use &dm_file_scorecode as your destination file in that case. If you hard-code score code in the score code pane, it will also be put in that file (without you explicitly referencing it).

The score code can be anything like a data mining preprocessing step on your data (it does not have to be a model).

Data flowing through the code node will be scored.

 

Tip: How to include the SAS Code node in SAS® Visual Data Mining and Machine Learning's Model Studio

https://communities.sas.com/t5/SAS-Communities-Library/Tip-How-to-include-the-SAS-Code-node-in-SAS-V...

 

BR, Koen

sbxkoenk
SAS Super FREQ

Why don't you use

Add child node -> Miscellaneous -> "Score Data" - node

??

 

This will allow you to score a table of your choice with the model that was built in the preceding supervised modeling node !

 

BR, Koen

acordes
Rhodochrosite | Level 12

Because I want to score a grid of points and visualize it. 

 

Here is the working example for a sas code node whose parent is a Gradient Boosting node. 

My challenge is to "macrotize" the scoring code that is generated from logistic regression for example.  

 

/* SAS code */

%put &_astore;

/* 1. Create grid in the project caslib */
data casuser.grid;
  do x = 0 to 200 by 1;
    do y = 0 to 200 by 1;
            group = rand("integer", 3); 
      output;
    end;
  end;
run;


proc astore;
   score data=casuser.grid
            rstore=&dm_output_lib..&_astore
         copyvars=(x y)
         out=casuser.grid_scored;
run;

ods graphics on;
proc sgplot data=casuser.grid_scored aspect=1;
  title "Decision Surface (Heatmap)";
  heatmap x=x y=y / colorresponse=&DM_PREDICTED_VVNVAR colorstat=mean;
run;
sbxkoenk
SAS Super FREQ

I think you have to select "Download score code" and then copy / paste. 

I understand that's not very dynamic though. When the model changes, you have to copy/paste again ... not very practical ...not very handy.

 

Another option is you use PROC LOGSELECT with the CODE statement. The CODE statement writes the body of the score-code data step to an external file. And you can %INCLUDE that external *.sas file in a subsequent step to score new data. 

 

In the PROC LOGSELECT you can avoid hard-coding table names and variable names. All you need is in automatic macro variables!

 

See also:

Using SAS Viya Data Step Score Code in SAS 9.4
https://communities.sas.com/t5/SAS-Communities-Library/Using-SAS-Viya-Data-Step-Score-Code-in-SAS-9-...

 

[EDIT] if you can download the score code, it is saved somewhere. I agree with you that you should be able to %INCLUDE that score code directly. I will try to find out about the location ! Could be next week ... .

 

Kind regards,

Koen

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore Now →
How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 240 views
  • 1 like
  • 2 in conversation