%MM_ScorePortfolioModels Macro

The %MM_ScorePortfolioModels macro supports scoring models that are within a portfolio.

Syntax

%MM_ScorePortfolioModels (
scoreInputDS=scoring-input-table,
scoreOutputDS=scoring-output-table,
workPath=input-directory-path,
modelDS=model-property-table-name,
portfolioScoreCode=scorecode-filename,
<codeFmt=DS | DS2> ,
<runScore=N | Y >
);

Required Arguments

scoreInputDS=score-input-table

Specifies the name of scoring input table.

scoreInputDS=score-output-table

Specifies the name of scoring output table.

workPath=input-directory-path

Specifies the input directory path for the downloaded model files. The default value is the directory path of the SAS work library if you do not specify a value.

modelDS=SAS-dataset-name

Specifies the name of the model property table that is generated from the %MM_CreateModelDataset macro.

portfolioScoreCode=score-code-filename

Specifies the full directory path and filename of the score code to be generated.

Optional Arguments

codeFmt=DS | DS2

Specifies the format for the generated score code. By default, the value is DS for DATA step score code.

runScore=N | Y

Specifies whether the generated score code should be executed. The default value is N, to not execute the score code.

Details

Here is the high-level process for the actions performed by this macro:
  1. Get model files for each model from a portfolio. The model files include inputvar.xml, MiningResult.xml, and so on.
  2. Generate the score code based on the model score code type of DATA step or analytic store.
  3. Combine all of the score code for the models into one SAS code file.
  4. Execute the score code.

Example: Generate Score Code

This example shows how to generate score code from a SAS Model Manage portfolio. In this example, there are five project segments inside the portfolio. There is one champion model for each project segment. The combined score code consists of the five models' score code.
/********************************************************************/
/* Generate score code for a SAS Model Manager portfolio             */
/********************************************************************/
filename score catalog 'SASHELP.modelmgr.MM_ScorePortfolioModels.source';
%include score;
filename score;
libname scorelib 'c:\temp';
%MM_ScorePortfolioModels(
    scoreInputDS=scorelib.hmeq_score_input,
    scoreOutputDS=scorelib.hmeq_score_output,
    workPath=c:\temp,
    modelDS=_models,
    portfolioScoreCode=c:\temp\portfolio_score.sas,
    codeFmt=DS,
    runScore=Y
);
SAS Model Manager Portfolio Score Code (Partial)
%let _MM_InputDS=scorelib.hmeq_score_input;
%let _MM_OutputDS=scorelib.hmeq_score_output;
%let _MM_nthreads=2;
 
/* Score Code for the segment: JOB='ProfExe' */
proc astore;
    performance details nthreads=&_MM_nthreads;
    score data=&_MM_InputDS(where=(JOB='ProfExe')) out=_seg_2_out 
    epcode="c:\temp\_seg_2_score.sas" store="c:\temp\_seg_2_score.sasast";
    run;
quit;
 
/* Score Code for the segment: JOB='Office' */
proc astore;
    performance details nthreads=&_MM_nthreads;
    score data=&_MM_InputDS(where=(JOB='Office')) out=_seg_3_out 
    epcode="c:\temp\_seg_3_score.sas" store="c:\temp\_seg_3_score.sasast";
    run;
quit;
 
/* Score Code for the segment: JOB='Other' */
proc astore;
    performance details nthreads=&_MM_nthreads;
    score data=&_MM_InputDS(where=(JOB='Other')) out=_seg_5_out 
    epcode="c:\temp\_seg_5_score.sas" store="c:\temp\_seg_5_score.sasast";
    run;
quit;
 
/* Score code for the segment: JOB='Self' */
data _seg_1_out;
    set &_MM_InputDS(where=(JOB='Self'));
*------------------------------------------------------------*;
* SAS Factory Miner Release: 14.2;
* SAS Release:           9.04.01M4P110916;
* Site Number:           00000001;
* Host:                  MYSERVER;
* Encoding:              utf-8;
* Java Encoding:         UTF8;
* Locale:                en_US;
* Project Path:          C:\SAS\Config\Lev1\AppData\FactoryMinerServer;
* Project Name:          FCMR_sasdemo_1434294488570;
* Segment Id:            8aa58f084df27e88014df29e0b430390;
* Segment Server Id:     7;
* Model Id:              8aa58f084df27e88014df29e8f4d074f;
* Generated by:          sasdemo;
* Date:                  14NOV2016:11:11:39
*------------------------------------------------------------*;
*------------------------------------------------------------* ;
* Segment:          8aa58f084df27e88014df29e0b430390;
* SegmentServerId:  7;
*------------------------------------------------------------* ;
if (trim(JOB) = 'Self')  then do;
*------------------------------------------------------------*;
* Node: Ids;
*------------------------------------------------------------*;
*------------------------------------------------------------*;
* Node: HPImp;
*------------------------------------------------------------*;
Label IMP_CLAGE = 'Imputed CLAGE';
Length IMP_CLAGE 8;
if missing("CLAGE"n) then IMP_CLAGE = 174.53622491;
else IMP_CLAGE ="CLAGE"n;
Label IMP_CLNO = 'Imputed CLNO';
Length IMP_CLNO 8;
if missing("CLNO"n) then IMP_CLNO = 23.026315789;
else IMP_CLNO ="CLNO"n;
Label IMP_DEBTINC = 'Imputed DEBTINC';
Length IMP_DEBTINC 8;
if missing("DEBTINC"n) then IMP_DEBTINC = 35.568005927;
else IMP_DEBTINC ="DEBTINC"n;
Label IMP_DELINQ = 'Imputed DELINQ';
Length IMP_DELINQ 8;
......
......
*------------------------------------------------------------*;
* Generating fixed output names;
*------------------------------------------------------------*;
Length EM_EVENTPROBABILITY 8;
LABEL EM_EVENTPROBABILITY = "Predicted: BAD=1";
EM_EVENTPROBABILITY =P_BAD1                          ;
LENGTH EM_CLASSIFICATION $32;
LABEL EM_CLASSIFICATION= "Prediction for BAD";
EM_CLASSIFICATION =I_BAD                           ;
Length EM_PROBABILITY 8;
LABEL EM_PROBABILITY = "Probability of Classification";
EM_PROBABILITY = max(P_BAD1,P_BAD0);
end;
run;
 
/* Collect all segment outputs */
data &_MM_OutputDS;
    set _seg_1_out _seg_2_out _seg_3_out _seg_4_out _seg_5_out;
run;
 
proc datasets nolist nodetails;
delete _seg_1_out _seg_2_out _seg_3_out _seg_4_out _seg_5_out _segDS ;
run;
quit;
Last updated: February 14, 2017