BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
saspert
Pyrite | Level 9

Hi,

Can anyone point out how to score a model using an external dataset in SAS Eminer 12.1?

Thanks,

saspert.

1 ACCEPTED SOLUTION

Accepted Solutions
jwexler
SAS Employee

To score your dataset in SAS Enterprise Miner, you add a score node at the end of your modeling flow.  You then add the data set you wish to score as in an input dataset with an arrow connected into the Score node. Change the role of the newly added dataset to Score in the Train properties.

 

To save the output dataset, add a Save Data node after the Score node.

Alternatively, you can use a SAS Code node in which case you would write a data step like the following to save a data set called NEWSCORES in the path defined by the libname statement for YOURLIB.

 

libname YOURLIB ' < path to library relative to where SAS EM is installed > ';

data YOURLIB.NEWSCORES;

set &EM_IMPORT_SCORE

RUN;

 

You can also export the score code by using the Score Export node after the Score node.  You can take these files and use the Scoring Accelerator to automatically publish this score code to a database, and then execute scoring inside the database.

View solution in original post

9 REPLIES 9
jakarman
Barite | Level 11

Getting Started with SAS(R) Enterprise Miner(TM) 12.3 (Score New Data)

Several options.
- score wiht your project (libname)

- generate the code SAS (JAVA and C possible needing compliation) and let it have that run

---->-- ja karman --<-----
saspert
Pyrite | Level 9

Hi Jaap,

Do you know if it is the same procedure whether the dataset is training or external?

Thanks,
Raj.

Reeza
Super User

What do you mean by "external data"?

SAS EMiner will provide the code to score the dataset. Take that code and export it to base SAS or put it in a program node and use it.

saspert
Pyrite | Level 9

Hi Reeza,

I wish I was a bit more articulate when it comes to Eminer. So the user has built a model using a sample dataset that he split 80:20 for training and validation. Now he wants to use this model on real world data to be able to score for each observation in the dataset. So, I just discussed with the user and he says he tried the score option like the SAS user documention page (also suggested above by Jaap) but it gives him source code in C /Java and summary statistics but no "scored dataset" per say. So, we were wondering how to get the scored dataset.

Reeza
Super User

The user should be able to export SAS code to score the dataset, not just in C/Java.  Then use that code to score the dataset in Base SAS or EG or whatever production environment you have.

EDIT:

From the docs:

Note: The SAS scoring code is viewable in the node results.

saspert
Pyrite | Level 9

Thanks. I guess I have to point out the user. So I picked up this code from the scoring node in Eminer and I am thinking this where the data references have to be changed.

%macro em_usedatatable;

%if ^%symexist(EM_USEDATATABLE) %then %do;

%let EM_USEDATATABLE = Y;

%end;

%if "&EM_USEDATATABLE" ne "N" %then %do;

%global Ids7_data Ids7_newdata;

%global Ids_data Ids_newdata;

*------------------------------------------------------------*;

* Data Tables;

*------------------------------------------------------------*;

%let Ids7_data = MES.Z17_FINAL_DATA;

%let Ids7_newdata =;

%let Ids_data = MES.Z17CENTER_PBG11A;

%let Ids_newdata = MES.Z17CENTER_PBG11A;

*------------------------------------------------------------*;

%end;

%global Ids7_source;

%if "&Ids7_newdata" ne "" %then %do;

%let Ids7_source = USERTABLE;

%end;

%else %do;

%let Ids7_source = DATASOURCE;

%end;

%global Ids_source;

%if "&Ids_newdata" ne "" %then %do;

%let Ids_source = USERTABLE;

%end;

%else %do;

%let Ids_source = DATASOURCE;

%end;

%mend em_usedatatable;

%em_usedatatable;

Reeza
Super User

That doesn't look like score code to me, but I don't understand your model at all.

The code from EM has to be put in a data step, you add in the data and set statements and the run.

It does assume the variable names are the same.

jakarman
Barite | Level 11

I just finished the miner ecourse, Miner is working in the semma approach.
The extraction stage and bootstrap options are steps outside miner.

Building models starts with splitting your input dataset in a train and validate (optional test) parts.

In this dataset input varibles and output (target) are known. Missing values to solve (imputation)
While building the model the training part is to get the models right. The test part to check on overtraining so getting the expectations on the real world (scoring).   With all steps miner takes a lot of the work on that between train and test.

Having your model, just some calculations on some input variables, you can go to the scoring step.

The same input variables must be present just the target is unknown (that was the goal of the model),

Perhaps you have access to that dataset, you can score within Miner

Perhaps someone wants the SAS-code (export that) to run that for you.

Perhaps it must be included in a JAVA or C execution.

Where the production data resides we can not know. It was started with modeling, so at that point it should be known by someone..          

---->-- ja karman --<-----
jwexler
SAS Employee

To score your dataset in SAS Enterprise Miner, you add a score node at the end of your modeling flow.  You then add the data set you wish to score as in an input dataset with an arrow connected into the Score node. Change the role of the newly added dataset to Score in the Train properties.

 

To save the output dataset, add a Save Data node after the Score node.

Alternatively, you can use a SAS Code node in which case you would write a data step like the following to save a data set called NEWSCORES in the path defined by the libname statement for YOURLIB.

 

libname YOURLIB ' < path to library relative to where SAS EM is installed > ';

data YOURLIB.NEWSCORES;

set &EM_IMPORT_SCORE

RUN;

 

You can also export the score code by using the Score Export node after the Score node.  You can take these files and use the Scoring Accelerator to automatically publish this score code to a database, and then execute scoring inside the database.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register 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
  • 9 replies
  • 4789 views
  • 0 likes
  • 4 in conversation