%MM_CombineModelScoreCode Macro

The %MM_CombineModelScoreCode macro combines the score code of models that are stored in SAS Model Manager portfolios into one SAS code file.

Syntax

%MM_CombineModelScoreCode(
<workPath=input-directory-path>,
modelDS=model-property-table-name,
portfolioScoreCode=scorecode-filename,
<codeFmt=DS | DS2>,
<ds2Mode=SCTHR | MAC | EP | PKGARGS >
);

Required Arguments

workPath=input-directory-path

Specifies the 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 generated portfolio score code.

Optional Arguments

codeFmt=DS | DS2

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

ds2Mode=SCTHR | MAC | EP | PKGARGS

Specifies the parameter. ds2Mode is typically used for translating DATA step code for the dynamic in-database projects in SAS Embedded Process. The default value is MAC. This parameter should be set only when codeFmt=DS2.

SCTHR This flag tells DSTRANS to generate a DS2 thread to represent the score code.
MAC This flag is similar to SCTHR, except that DSTRANS generates a data statement instead of a thread, and uses macro names that are related to the SAS Embedded Process.
EP This flag is generic for all SAS Embedded Process projects. These are similar to the SCTHR flag, but instead of a thread, a DATA step is generated. For these flags, the input and output tables are hardcoded to the SAS Embedded Process virtual table names SASEP.OUT and SASEP.IN, rather than using the macros.
PKGARGS This flag tells DSTRANS to generate a real DS2 package instead of the C code PKG version. The PKGARGS package has standard DS2 parameters for the inputs and outputs instead of C structures.

Details

Here is the high-level process for the actions performed by this macro:
  1. Get model files for each project champion model that is within a portfolio. The model files include score.sas, MiningResult.xml, and so on.
  2. Combine all of the score code for the models into one SAS code file.
  3. Transfer the combined score code to DS2 format if the user sets the macro parameter codeFmt=DS2.
  4. Create a model SAS package file and register the model into the SAS Model Manager model repository.

Example: Combine Champion Model Score Code and a Register Model SAS Package File

******************************************************************/
/* Step 1: Get all champion models from the specified portfolio  */
/*****************************************************************/ 
%let _MM_User=sasdemo;
%let _MM_Password=mypassword; 
/* SAS Model Manager portfolio UUID */ 
%let FMUUID=%nrstr(0ab98ee1-0a25-0f88-7dac-5ce40c19a999);
 
/* set up metadata connections */
options metaPort=8561 
metaServer=myserver.sas.com
metaRepository=Foundation
metaUser=sasdemo 
metaPass=xxx;
 
filename MMAccess catalog 'SASHELP.modelmgr.AccessMacros.source';
%include MMAccess;
filename MMAccess;
 
filename mmfm catalog 'SASHELP.modelmgr.MM_CombineModelScoreCode.source';
%include mmfm;
filename mmfm;
 
%let _MM_RC= -1;
%let propertyName = %str(ProjectName FolderName name projectuuid modeluuid 
                         isdefaultversion ischampion projectpath projecturl 
                         versionname tool scorecodetype);                                                                                               
%MM_CreateModelDataset(
    mDatasetName=_models,
    smmpath=%superq(FMUUID),
    propertyName=&propertyName,
    isChampion=Y,
    trace=ON);
 
/***************************************************************************/
/* Step 2: Create a combined score code for the portfolio champion models  */
/***************************************************************************/
%let _MM_Portfolio_Scorecode=c:\temp\portfolio_score.sas;
%MM_CombineModelScoreCode(
    workPath=c:\temp,
    modelDS=_models,
    portfolioScoreCode=&_MM_Portfolio_Scorecode
);
 
/*******************************************************************************/
/* Step 3: Create an SPK file and register it in the SAS Metadata Repository   */
/*******************************************************************************/
 
libname mmlib "C:\SMM142Tutorials\Data"; 
%aamodel;
%aa_model_register(
   modelname=FMSegCombined, 
   modeldesc=%nrbquote(The combined DATA step model), 
   data=mmlib.hmeq_train,
   target=bad,
   level=binary,
   scorecodefile=&_MM_Portfolio_Scorecode,
   scorecodeformat=DATASTEP,
   register=N, 
   spk=Y, 
   spkfolder=c:\temp, 
   miningfunction=classification
);
 
%put &aa_spk_folderid;
 
/**************************************************************************/
/* Step 4: Register the model SPK file to SAS Model Manager               */
/**************************************************************************/
filename spkmod1 "&aa_spk_folderid.\miningResult.spk";
 
%let _MM_RC= -1; /* set to detect failure in case macro fails */
 
%let targetVersion=//ModelManagerDefaultRepo/MMRoot/Folder1/HMEQ/1.0;
 
%MM_Register( VersionId=&targetVersion,
              EMModelPackage=spkmod1,
              ModelName=FM_Combined_Model,
              trace=on);
%put %trim(&_MM_CID);
Last updated: February 14, 2017