%MM_Register Macro

Registers a model to an existing version in the SAS Model Manager model hierarchy.

Syntax

%MM_Register(
VersionId=destination-version-UUID,
ModelTemplate=model-template-name,
EMModelPackage=SAS-fileref-for-EM-package-file,
ScoreDataStepCode=fileref-to-data-step-fragment-score-code,
ScoreProgram=fileref-to-SAS-program-score-code,
InDataSamp=SAS-data-set-reference-to-input-data-sample-table,
InDataInfo=SAS-data-set-reference-tor-input-variable-metadata-table,
OutDataSamp=SAS-data-set-reference-for-output-data-sample-table,
OutDataInfo=SAS-data-set-reference-for-output-variable-metadata-table,
TargetDataSamp=SAS-data-set-reference-for-target-data-sample-table,
TargetDataInfo=SAS-data-set-reference-for-target-variable-metadata-table,
TrainingDataSamp=SAS-data-set-reference-for-training-data-sample-table,
LogisticOutModelTable=SAS-data-set-reference-for-PROC-LOGISTIC-outmodel-table,
ReportDir=path-to-EMREPORT-directory,
KeepInVars=keep-variable-list-for-InDataSamp,
KeepOutVars=keep-variable-list-for-OutDataSamp,
KeepTargetVars=keep-variable-list-for-TargetDataSamp,
ModelName=model-name,
Description=model-description,
Label=model-label,
Subject=model-subject,
Algorithm=model-algorithm,
Function=model-function,
Modeler=modeler-property,
Tool=model-tool-property,
ToolVersion=model-tool-version,
Trace=ON | OFF
);

Arguments

Note: If a %MM_Register macro parameter contains a semicolon, comma, apostrophe, or quotation mark (; , ' ") character, you must add %bquote to the macro parameter. For example, you could specify %MM_Register(..., Description=%bquote(My Division's Model), ... );

VersionId=destination-version-UUID

specifies the SAS Model Manager UUID for an existing version in the SAS Model Manager model repository.

Default the value of the _MM_CId macro variable
Note This argument is required.

ModelTemplate=model-template-name

specifies the SAS Model Manager model template that was used to register and validate this model.

Default For models that were registered using the EMModelPackage parameter, the template is set according to the information that is contained within the named SAS Enterprise Miner model package file.
Models that were registered using the LogisticOutModelTable parameter are registered with the Classification template.
All other registrations default to the AnalyticalModel template.

EMModelPackage=SAS-fileref-for-EM-package-file

specifies a SAS file reference that points to the Enterprise Miner model package file (SPK) that contains the model to be registered.

Note The EMModelPackage argument is required unless you use the ReportDir argument, the ScoreDataStepCode argument, or the ScoreProgram argument to specify the model code filename.

ScoreDataStepCode=fileref-to-data-step-fragment-score-code

specifies a SAS file reference for the model score code that is a fragment of SAS code that can be included in a DATA step. A DATA step fragment contains no DATA, PROC, or RUN statements.

Note The ScoreDataStepCode argument is required unless you use the EMModelPackage argument, the ReportDir argument, or the ScoreProgram argument to specify the model code filename.

ScoreProgram=fileref-to-SAS-program-score-code

specifies a SAS file reference for a text file containing the SAS program, including all step code that is required for successful execution of the model score code.

Note The ScoreProgram argument is required unless you use the EMModelPackage argument, the ReportDir argument, or the ScoreDataStepCode argument to specify the model code filename.

InDataSamp=SAS-data-set-reference-to-input-data-sample-table

specifies a two-level SAS data set reference in the form libref.filename that points to a model input data sample table. The input data sample table is a table that contains all model input variables and is used to create the inputvar.xml file that is required for model registration. The input data sample table is not required for models that were imported as SAS Enterprise Miner package files.

Note The InDataSamp argument is required unless you use the InDataInfo argument.
Tip When you use the %MM_Register macro to register a model, the inputvar.xml file should contain only input variables for the model that you are registering. If the input data sample table includes variables that are not used by the model, use the KeepInVars argument to remove these variables. If no variables are specified by the KeepInVars argument, SAS filters the target variables from the table specified by the InDataSamp argument.
See KeepInVars argument

InDataInfo=SAS-data-set-reference-for-input-variable-metadata-table

specifies a two-level SAS data set reference in the form libref.filename that points to a model input variable metadata table. The input variable metadata table should be in the form of a CONTENTS procedure output file, which has the columns NAME, TYPE, LENGTH, LABEL, FORMAT, LEVEL, and ROLE. Each row of the table is a variable. The model input variable metadata table is used to create the inputvar.xml file that is required for model registration.

Note The InDataInfo argument must be specified unless you use the InDataSamp argument.
Tip When you use the %MM_Register macro to register a model, the inputvar.xml file should contain only variables for the model that you are registering. If no variables are specified in the KeepInVars argument, SAS filters the target variables from the table specified by the InDataInfo argument.
See The CONTENTS Procedure in the Base SAS Procedures Guide

OutDataSamp=SAS-data-set-reference-for-output-data-sample-table

specifies a two-level SAS data set reference in the form libref.filename that points to a model output data sample table. The output data sample table should contain all variables that are created or modified by the model and is used to create the outputvar.xml file that is required for model registration. The output data sample table is not required for models that were imported as SAS Enterprise Miner package files.

Interaction If the output data sample table includes variables that are created or modified by the model, use the KeepOutVars argument to remove these variables. If no variables are specified in the KeepOutVars argument, SAS filters the input variables and the target variables from the table that is specified by the OutDataSamp argument.
Note The OutDataSamp argument must be specified unless you use the OutDataInfo argument.
See KeepOutVars argument

OutDataInfo=SAS-data-set-reference-for-output-variable-metadata-table

specifies a two-level SAS data set reference in the form libref.filename that points to a model output variable metadata table. The output variable metadata table should contain all of the variables that are created or modified by the model. The SAS file should be in the form of the CONTENTS procedure output file, which has the columns NAME, TYPE, LENGTH, LABEL, FORMAT, LEVEL, and ROLE. Each row of the table contains a variable. The output variable metadata table is used to create the outputvar.xml file that is required for model registration.

Interaction If no variables are specified by the KeepOutVars argument, SAS filters the input variables and target variables from the table that is specified by the OutDataInfo argument.
Note The OutDataInfo argument must be specified unless you use the OutDataSamp argument.

TargetDataSamp=SAS-data-set-reference-for-target-data-sample-table

specifies a two-level SAS data set reference in the form libref.filename. The data set reference points to a SAS table that contains the model target variable. The SAS file should contain the variable that was used as the model target during training. The SAS file is used to create the target variable information in the targetvar.xml file that is used for SAS Model Manager model registration.

Tip If the target data sample table includes other variables that are not model target variables, use the KeepTargetVars argument to remove these variables.
See KeepTargetVars argument

TargetDataInfo=SAS-data-set-reference-for-target-variable-metadata-table

specifies a two-level SAS data set reference in the form libref.filename. The data set reference points to a SAS table that contains the model's target variable and its metadata. The SAS file should be in the form of the CONTENTS procedure output file, which has the columns NAME, TYPE, LENGTH, LABEL, FORMAT, LEVEL, and ROLE. Each row of the table contains a variable. The metadata in the SAS file is used to create the target variable information in the target.xml file that is used for SAS Model Manager model registration.

TrainingDataSamp=SAS-data-set-reference-for-training-data-sample-table

specifies a two-level SAS data set reference in the form libref.filename. The data set reference points to a SAS file that contains the training data that is used for a model created by the LOGISTIC procedure. The training data sample must be an exact sample of the training data that is submitted to the LOGISTIC procedure. When the TrainingDataSamp argument and the LogisticOutModelTable argument are specified, the %MM_Register macro can derive the input, output, and target variables to create the inputvar.xml file, the ouputvar.xml file, and the targetvar.xml file.

LogisticOutModelTable==SAS-data-set-reference-for-PROC-LOGISTIC-outmodel-table

specifies a two-level SAS data set reference in the form libref.filename that points to a LOGISTIC procedure fit table that was created by using the PROC LOGISTIC OUTMODEL= statement, and is suitable for use with the PROC LOGISTIC INMODEL statement. If the TrainingDataSamp argument is specified, then SAS generates the input, output, and target variable metadata from this table. In this case, the InDataSamp and the OutDataSamp arguments do not need to be specified.

Note This argument is required only if the model is created by the LOGISTIC procedure using the OUTMODEL statement.

ReportDir=path-to-EMREPORT-directory

specifies an absolute file path to the EMREPORT directory that was created by the SAS Enterprise Miner batch code. All SAS Enterprise Miner model packages that are named miningResult.spk and that reside in a subdirectory of the EMREPORT directory are registered to the target version. The ReportDir argument is valid only for use with SAS Enterprise Miner model package files.

KeepInVars=keep-variable-list-for-InDataSamp

specifies a list of input variables or columns that are retained in the model's inputvar.xml file. Only variables from the table that is specified by the InDataSamp argument can be specified in this list.

See InDataSamp argument

KeepOutVars==keep-variable-list-for-OutDataSamp

specifies a list of variables or columns that are retained in the model's outputvar.xml file. Only variables from the table that is specified by the OutDataSamp argument can be specified in this list.

See OutDataSamp argument

KeepTargetVars=keep-variable-list-for-TargetDataSamp

specifies a list of variables or columns that are retained in the model's targetvar.xml file. Only variables from the tables that are specified by the TargetDataSamp argument can be specified in this list.

See TargetDataSamp argument

ModelName=model-name

specifies the name of the model, which is used as the value of the model Name property on the General tab of the Models Properties page.

Note This argument is required.

Description=model-description

specifies a description of the model, which is used as the value of the model Description property on the General tab of the Models Properties page.

Label=model-label

specifies a model's label, which is used as the value for the model Model label property on the Specific tab of the Models Properties page. model-label is a text string that is used as the label for the selected model in the model assessment charts that SAS Model Manager creates. If model-label is not specified, SAS Model Manager uses the text string that is specified for the ModelName argument.

Subject=model-subject

specifies the model's subject, which is used as the value for the model Subject property on the Specific tab of the Models Properties page. model-subject provide an additional description for a model, such as a promotional or campaign code. This property is not tied to any computational action by SAS Model Managerr.

Algorithm=model-algorithm

specifies the model's computation algorithm, which is used as the value of the model Algorithm property on the Specific tab of the Models Properties page.

Example Algorithm=Decision Tree

Function=model-function

specifies the model's function class, which is used as the value for the model Function on the Specific tab of the Models Properties page. Valid values are Classification, Prediction, Association, Clustering, Sequence, Forecasting, TextMining, Transformation, and EMCreditScoring.

Modeler=model-creator

specifies the SAS Model Manager user ID for the person who created the model, which is used as the value of the model Modeler property on the Specific tab of the Models Properties page.

Tool=model-tool

specifies the modeling tool that was used to create the model, and that is used as the value of the model Tool property on the Specific tab of the Models Properties page.

ToolVersion=model-tool-version

specifies the version of the tool that was used to create the model, and that is used as the value of the model Tool version property on the Specific tab of the Models Properties page.

Trace=ON | OFF

specifies whether to supply verbose trace messages to the SAS log.

Default OFF
Example
trace=on

Details

Overview of Using the %MM_Register Macro
The %MM_Register macro registers the following types of models to an existing version in the SAS Model Manager model repository:
  • a model as a SAS Enterprise Miner package
  • a SAS DATA step fragment
  • a SAS program
In order to register a model using the %MM_Register macro, the macro must know the model name, the version in which the model is registered, the model source code, the model template, and the model input and output variables. If you register a SAS Enterprise Miner model, this information is included in a SAS Enterprise Miner package file (SPK file). When you register SAS code models, you must specify the model name, version, and model score code, as well as the model input and output variables in the respective macro arguments. Several %MM_Register macro arguments enable you to provide values for model property values that appear on the Models Properties page.
Registering SAS Enterprise Miner Models
Models that were created in SAS Enterprise Miner and saved as a SAS Enterprise Miner SPK file contain all of the information that is needed to register a model in SAS Model Manager. Registering SAS Enterprise Miner SPK files requires you to specify the following arguments:
  • ModelName
  • VersionId
  • EMModelPackage or ReportDir arguments
To register one SAS Enterprise Miner model, you can specify the EMMModelPackage argument. To register multiple SAS Enterprise Miner models, you use the ReportDir argument to name a directory whose subdirectories each contain a miningResult.spk file. You can register multiple models simultaneously in SAS Model Manager.
SAS Enterprise Miner generates a program, EMBatch, to create multiple models in a batch program. You can modify the EMBatch program to include the %MM_Register macro, using the macro variable &EMREPORT as the value of the ReportDir argument. By making this change to the EMBatch program, you can create and register SAS Enterprise Miner models in a batch program for use in SAS Model Manager.
Registering SAS Code Models
When you register SAS code models, the information that is required is not contained in an SPK file and you must specify the required information using the %MM_Register arguments. Each model that you register must specify the model name, the model version, the model template, the model code, and the SAS data sets that describe the input, output, and target variables.
Use the following table for usage information about using the %MM_Register arguments:
Required Information
Argument
Usage
model name
ModelName
Specify the name of the model, which is used to identify the model in the SAS Model Manager model repository.
version
VersionId
Specify the name of the version in which the model is registered.
model score code
Specify one of the following arguments:
  • ScoreDataStepCode
  • ScoreProgram
  • LogisticOutModelTable
ScoreDataStepCode
Specify a fileref that points to a file that contains score code that is a DATA step fragment. A DATA step fragment contains no DATA, PROC, or RUN statements.
When you specify the ScoreDataStepCode argument, your model input and output variables can be defined using one of the following pairs of arguments:
  • InDataSamp and OutDataSamp
  • InDataInfo and OutDataInfo
  • InDataSamp and OutDataInfo
ScoreProgram
Specify a LOGISTIC procedure FIT table in the form libref.filename that was created by the PROC LOGISTIC OUTMODEL= statement. The FIT table can be used as the value in a PROC LOGISTIC INMODEL= statement.
When you specify the ScoreProgram argument, your model input and output variables can be defined using one of the following pairs of arguments:
  • InDataSamp and OutDataSamp
  • InDataInfo and OutDataInfo
LogisticOutModelTable
Specify a libref.filename that points to a LOGISTIC procedure FIT table that was created by the PROC LOGISTIC OUTMODEL= statement, which can be used as the value to a PROC LOGISTIC INMODEL= statement.
If the model does not contain data transmission and you specify a value for the TrainingDataSamp argument, SAS Model Manager uses the training sample data set and the FIT table to create the model inputvar.xml file, the outputvar.xml file, and the targetvar.xml file.
If you do not specify a value for the TrainingDataSamp argument or if your program transforms the model input before running the LOGISTICS procedure, you must provide the model input and output variables using the InDataSamp or InDataInfo argument, and the OutDataSamp or OutDataInfo argument.
input variables
InDataSamp
Specify a fileref to a SAS data set whose variables contain the input variables that are used by the SAS code model. An example would be a data set that was used for training the model.
SAS Model Manager reads one observation in the data set that is specified by the InDataSamp argument to create the inputvar.xml file for the model. The inputvar.xml file defines the model input variables and their metadata.
Based on the arguments that were specified, the %MM_Register macro uses arguments to filter variables from the data set to create the inputvar.xml file.
  • You can use the KeepInVars argument to specify the variables in the InDataSamp data set that are used to create the inputvar.xml file.
  • If you do not specify the KeepInVars argument, you can specify a value for the TargetDataSamp argument or the TargetDataInfo argument to filter variables based on this target data sample data set.
For more information, see KeepInVars argument.
InDataInfo
Specify a fileref that points to a SAS data set whose variables are NAME, TYPE, LENGTH, LABEL, FORMAT, LEVEL, and ROLE. These variables define metadata for the model input variables. Each row in this data set contains the metadata for model input variables. Such a table can be created by the CONTENTS procedure.
SAS Model Manager reads the data set that is specified by the InDataInfo argument to create the inputvar.xml file for the model. The inputvar.xml file defines the model input variables and their metadata.
The variables in the data set that are specified by the TargetDataSamp argument or the TargetDataInfo argument are used as a filter to create the inputvar.xml file.
output variables
OutDataSamp
Specify a fileref that points to a SAS data set whose variables contain the output variables that are created or modified by the SAS code model. An example is a data set that was the scored output of the model.
SAS Model Manager reads the data set that is specified by the OutDataSamp argument to create the outputvar.xml file for the model. The outputvar.xml file defines the model output variables and their metadata.
Based on the arguments that were specified, the %MM_Register macro uses arguments to filter variables from the data set to create the outputvar.xml file.
  • You can use the KeepOutVars argument to specify the variables in the OutDataSamp data set that are used to create the outputvar.xml file.
  • If you do not specify the KeepOutVars argument, input variables and target variables are filtered from the output table.
For more information, see KeepOutVars argument.
OutDataInfo
Specify a fileref that points to a SAS data set whose variables are NAME, TYPE, LENGTH, LABEL, FORMAT, LEVEL, and ROLE. These variables define metadata for the model output variables. Each row in this data set contains the metadata for model output variables. Such a table can be created by the CONTENTS procedure.
SAS Model Manager reads the data set that is specified by the OutDataInfo argument to create the outputvar.xml file for the model. The outputvar.xml file defines the model output variables and their metadata. If you do not specify the KeepOutVars argument, input variables and target variables are filtered from the output table.
target variable
TargetDataSamp
Specify a fileref that points to a SAS data set whose variables contain the target variable that is created or modified by the SAS code model. An example is a data set that was the scored output of the model.
SAS Model Manager reads the data set that is specified by the TargetDataSamp argument to create the targetvar.xml file for the model. The targetvar.xml file defines the target output variable and its metadata.
You can use the KeepTargetVars argument to specify the variable in the TargetDataSamp data set that is used to create the targetvar.xml file.
TargetDataInfo
Specify a fileref that points to a SAS data set whose variables are NAME, TYPE, LENGTH, LABEL, FORMAT, LEVEL, and ROLE. These variables define metadata for the model target variable. A row in this data set contains the metadata for the model target variable. Such a table can be created by the CONTENTS procedure.
SAS Model Manager reads the data set that is specified by the TargetDataInfo argument to create the targetvar.xml file for the model. The targetvar.xml file defines the model target variable and its metadata.
Use the %MM_AddModelMfile macro to register other model component files that are not registered by the %MM_Register macro. For more information, see Model Templates and %MM_AddModelFile Macro.

Examples

Example 1: Registering a SAS Enterprise Miner Model Package

/*****************************************************/
/* Registering a SAS Enterprise Miner Model Package. */
******************************************************/

Options NOmlogic NOmprint NOspool;

/*****************************************************/
/*  Access and load the Model Management macro code.*/
/*****************************************************/

Filename MMAccess catalog 'SASHELP.modelmgr.AccessMacros.source';
%include MMAccess;

/* Fileref to the encoded  password                  */

FILENAME pwfile 'my-network-path\pwfile'; 

/*****************************************************/
/* Set SAS WIP Server variables. *********************/
/*****************************************************/

%let _MM_Service_Registry_URL=
   %STR(http://abcdef.sas.com:7980/SASWIPClientAccess/remote/ServiceRegistry); 
%let _MM_User = miller;
data _null_;
   infile pwfile obs=1 length=l; 
   input @;
   input @1 line $varying1024. l; 
   call symput('_MM_Password',substr(line,1,l)); 
run;

/*****************************************************/
/* Specify the path for a SAS Enterprise             */
/* Miner Model Package file miningResult.spk.        */
/*****************************************************/

FILENAME EMPak 'c:\myscorecode\EM\miningResult.spk';

/*****************************************************/
/* Set to detect failure in case macro load fails    */
/* and register the Enterprise Miner model.          */
/*****************************************************/

%let _MM_RC= -1; 


%MM_Register( 
  VersionId=
    //ModelManagerModelRepos/MMRoot/HomeEquity/HMEQ/2013,
  EMModelPackage=EMPak,
  ModelName=HMEQ,
  Description=Home Equity Score Code,
  Modeler=Titus Groan,
  Function=Reg,
  Tool=SAS Enterprise Miner,
  ToolVersion=v12.1,
  Subject= Loan,
  Trace=ON);

/*****************************************************/
/* Display MM_Register defined variables.            */
/*****************************************************/

Options nosource;
%PUT _MM_RC = &_MM_RC;
%PUT _MM_CId = &_MM_CId;
Options source;

Example 2: Registering a Generic Model

/**************************************************/
/* Registering a generic model.                      */
/*****************************************************/

Options nomlogic nomprint nospool;

/*****************************************************/
/* Load and access the Model Management macro code. */
/*****************************************************/

Filename MMAccess catalog 'SASHELP.modelmgr.AccessMacros.source';
%include MMAccess;

/* Fileref to the encoded password                   */

FILENAME pwfile 'my-network-path\pwfile'; 

/*****************************************************/
/* Set the SAS WIP Server variables.                 */
/*****************************************************/

%let _MM_Service_Registry_URL=
   %STR(http://abcdef.sas.com:7980/SASWIPClientAccess/remote/ServiceRegistry); 
%let _MM_User = miller;
data _null_;
   infile pwfile obs=1 length=l; 
   input @;
   input @1 line $varying1024. l; 
   call symput('_MM_Password',substr(line,1,l)); 
run;

/******************************************************/
/* Specify the location of the files.                 */
/******************************************************/

LIBNAME modelTbl 'c:\myModel\tables';
FILENAME Code 'c:\myModel\scoreCode';

/******************************************************/
/* Set to detect failure in case macro load fails     */
/* and register the model in the model repository        */
/******************************************************/

%let _MM_RC= -1; 

%MM_Register( 
  VersionId=
   //ModelManagerModelRepos/MMRoot/HomeEquity/HMEQ/2013,
  ScoreDataStepCode=CODE,
  InDataSamp=modelTbl.HMEQInput,
  OutDataSamp=modelTbl.HMEQOutput,
  TargetDataSamp=modelTbl.HMEQTarget,
  ModelName=HMEQDTree,
  Description= Home Equity model Added with a SMM Macro,
  Trace=ON);

/****************************************************/
/* Display the defined variables. */
/****************************************************/

Options nosource;
%PUT _MM_RC = &_MM_RC;
%PUT _MM_CId = &_MM_CId;
Options source;

Example 3: Registering a PROC LOGISTIC OUTMODEL-Style Model

/*****************************************************/
/* Registering a PROC LOGISTIC OUTMODEL-style model. */
/*****************************************************/

Options nomlogic nomprint nospool;

/*****************************************************/
/* Load and access the Model Management macro code. */
/*****************************************************/

Filename MMAccess catalog 'SASHELP.modelmgr.AccessMacros.source';
%include MMAccess;

/* Fileref to the encoded password                   */

FILENAME pwfile 'my-network-path\pwfile'; 

/*****************************************************/
/* Set the SAS WIP Server variables.                  */
/*****************************************************/

%let _MM_Service_Registry_URL=
   %STR(http://abcdef.sas.com:7980/SASWIPClientAccess/remote/ServiceRegistry); 
%let _MM_User = miller;
data _null_;
   infile pwfile obs=1 length=l; 
   input @;
   input @1 line $varying1024. l; 
   call symput('_MM_Password',substr(line,1,l)); 
run;

/*****************************************************/
/* Specify the location of the files.                */
/*****************************************************/

LIBNAME modelTbl 'c:\myModel\Tables';
LIBNAME trainTbl 'c:\HomeEquity\Tables';
FILENAME ProgCode 'c:\myModel\scoreCode';

/*****************************************************/
/* Set to detect failure in case macro load fails    */
/* and register the model                            */
/*****************************************************/
  
%let _MM_RC= -1; 

%MM_Register(
  VersionId=
   //ModelManagerModelRepos/MMRoot/HomeEquity/HMEQ/2013,
  ScoreProgram=ProgCODE,
  LogisticOutModelTable=modelTbl.HMEQProcLogisticOutput,
  TrainingDataSamp=trainTbl.HMEQTraining,
  ModelName=HMEQLogisticOutmodel,
  Description=HMEQ Logistic OUTMODEL model added by macro,
  Trace=off);

/******************************************************/
/* Display the defined variables.   */
/******************************************************/
  
Options nosource;
%PUT _MM_RC = &_MM_RC;
%PUT _MM_CId = &_MM_CId;
Options source;