Dictionary of Access Macros

%MM_AddModelFile Macro

Overview of the %MM_AddModelFile Macro

You use the %MM_AddModelFile macro to add model component files to an existing SAS Model Manager model.

Syntax

%MM_AddModelFile (
ModelId=path-to-model,
SASDataFile=path-to-SAS-file | SASCatalog=path-to-SAS-catalog | TextFile=path-to-text-file |
BinaryFile=path-to-binary-file
<, Name=alternateFileName><>
, Trace=OFF | ON
);

Arguments

ModelId=path-to-model
specifies a SAS Model Manager identifier of the model in the SAS Model Manager repository. The identifier specifies the location in the SAS Model Manager repository where the file is to be added. path-to-model can be either a SAS Model Manager UUID or a SAS Model Manager path. ModelId is a required argument. The default value is the value of the _MM_CId macro variable.
Examples ModelId=8904daa1-0a29-0c76-011a-f7bb587be79f
ModelId=//ModelManagerDefaultRepo/MMRoot/DDHMEQ/HomeEquity/2012/Models/HMEQ%20Loan%20Project
SASDataFile=path-to-SAS-file
specifies the path to a SAS data set to add to a model in the SAS Model Manager repository. path-to-SAS-file must be a two-level path in the form libref.filename.
Example SASDataFile=mysascode.hmeqloan
SASCatalog=path-to-SAS-catalog
specifies the path to one or more SAS code model component files to add to a model in the SAS Model Manager repository. path-to-SAS-catalog must be a two-level path in the form libref.catalog. Use the SASCatalog argument to add the catalog to a model.
Example SASCatalog=mylib.modelinput
TextFile=path-to-text-file
specifies the path to a SAS code model component file that is an ASCII text file. path-to-text-file is a one-level SAS name to a model component file.
Example TextFile=inputxml
BinaryFile=path-to-binary-file
specifies the path to a SAS code model component file that is a binary file. path-to-binary-file is a one-level SAS name to a model component file that is not a text file.
Example BinaryFile=gainscsv
Name=alternateFileName
specifies a name for the file that you are adding. Use the Name argument when your model component filename does not follow the SAS Model Manager model component file naming convention that is specified in the model's template file or your model requires a file to have a particular filename. If Name is not specified, the filename that is registered is the name of the file.
Example Name=score.sas
Trace=ON | OFF
specifies whether to supply verbose trace messages to the SAS log.
Default OFF
Example Trace=on

Details

For models that require model component files other than the score code, you can use the %MM_AddModelFile macro to add model component files to a registered model, one file at a time. All files that are added using the %MM_AddModelFile macro are placed in the SAS Model Manager repository. After files have been added, you can view the files in the model folder in the Project Tree.
The %MM_AddModelFile macro supports two types of files, text and binary. Text files are ASCII files that contain character data. Binary files are files created by an application in a format specific to that application. If you are adding a text file, you must use the TextFile argument to specify the file. To avoid any unintentional character translations, all non-text files should be added using the BinaryFile argument.
SAS data sets and SAS catalogs are both binary files. Instead of using the BinaryFile argument to add SAS files, you can use the SASDataFile and SASCatalog arguments respectively to add files using the SAS two-level references libref.filename or libref.catalog. The TextFile and BinaryFile arguments require a single SAS filename that can be a fileref.
The ModelId argument defaults to the value of the global variable _MM_CId. For example, after a call to the %MM_Register macro, the _MM_CId variable is set to the identifier for the registered model. In this case, you can use the %MM_AddModelFile macro to add additional component files to your model without having to explicitly specify the ModelId argument.
When you use the %MM_AddModelFile macro to add a component file to your SAS Model Manager model, the name of the added component file remains unchanged by default. If you need to change the name of the component file when you save it to a SAS Model Manager model, you can use the Name argument to specify the new component filename. Whenever possible, you should try to follow the component file naming conventions that are specified in the model's template file. When you use the model template file naming conventions, you are less likely to be confused about filenames.

Example

/****************************************/
/* Adding a file to a registered model.            */
/***************************************************/

Options NOmlogic NOmprint NOspool;

/***************************************************/
/* Get the SAS Model Manager 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_MulticastAddress=239.27.18.213;
%let _MM_MulticastPort=8561;
%let _MM_User=sasdemo;
data _null_;
   infile pwfile obs=1 length=l; 
   input @;
   input @1 line $varying1024. l; 
   call symput('_MM_Password',substr(line,1,l)); 
run;

/***************************************************/
/* A LIBNAME for a table.                          */
/***************************************************/
  
LIBNAME mtbls 'c:\mysascode';

/***************************************************/
/* Set to detect failure in case macro load fails  */
/* and add the input data source.                  */
/***************************************************/
  
%let _MM_RC= -1; 

%MM_AddModelFile(
  ModelId=
   //ModelManagerRepo/MMRoot/HomeEquity/HMEQ/2012/hmeqDecTree1,
  Name=modelinput.sas7bdat,
  SASDataFile=mtbls.myInputVariables,
  Trace=Off
);

/***************************************************/
/* A FILENAME for a text file.                     */
/***************************************************/

FILENAME tcode 'c:\myModel\inputvar.xml';

/***************************************************/
/* Set to detect failure in case macro load fails  */
/* and add the xml file for the input data source  */
/***************************************************/
  
%let _MM_RC= -1; 

%MM_AddModelFile(
  ModelId=
   //ModelManagerRepo/MMRoot/HomeEquity/HMEQ/2012/hmeqDecTree1,
  TextFile=tcode,
  Trace=on);

%MM_GetModelFile Macro

Overview of the %MM_GetModelFile Macro

Use the %MM_GetModelFile macro in a SAS program to access files in the SAS Model Manager repository. This macro copies the specified model file to the specified location on a local or network computer.

Syntax

%MM_GetModelFile (
ModelId=path-to-model | VersionId=path-to-version | ProjectId=path-to-project,
SASDataFile=path-to-SAS-data-file | SASCatalog=path-to-SAS-catalog |
TextFile=path-to-text-file | BinaryFile=path-to-binary-file
<, Name=alternateFileName>
<, Trace=ON | OFF>
);

Arguments

ModelId=path-to-model
specifies a SAS Model Manager identifier to the model in the SAS Model Manager repository. path-to-model can be either a SAS Model Manager UUID or a SAS Model Manager path that describes the location of the specific model. ModelId is a required argument. The default value is the value of the _MM_CId macro variable.
Examples ModelId=b2341a42-0a29-0c76-011a-f7bb7bc4f1e9
ModelId=//ModelManagerDefaultRepo/MMRoot/DDHMEQ/HomeEquity/2012/Models/HMEQ%20Loan%20Project
VersionId
specifies a SAS Model Manager identifier of the version folder to where a champion model resides in the SAS Model Manager repository. path-to-version can be either a SAS Model Manager UUID or a SAS Model Manager path that describes the location of the version.
Examples VersionId=b23327cb-0a29-0c76-011a-f7bb3d790340
VersionId=//ModelManagerDefaultRepo/MMRoot/DDHMEQ/HomeEquity/2012
ProjectId
specifies a SAS Model Manager identifier of the project folder. The identifier specifies the location where the champion model under the default version resides in the SAS Model Manager repository. path-to-project can be either a SAS Model Manager UUID or a SAS Model Manager path that describes the location of the project.
Examples VersionId=b232d766-0a29-0c76-011a-f7bb50921b42
VersionId=//ModelManagerDefaultRepo/MMRoot/DDHMEQ/HomeEquity
SASDataFile=path-to-SAS-file
specifies the destination path for a SAS data set. path-to-SAS-file must be a two-level path in the form libref.filename.
Example SASDataFile=mylib.modelinput
SASCatalog=path-to-SAS-catalog
specifies the SAS catalog to store a SAS catalog file. path-to-SAS-catalog must be a two-level path in the form libref.catalog.
Example SASCatalog=mylib.format
TextFile=path-to-text-file
specifies the destination path for a component file that is an ASCII text file. path-to-text-file is a one-level path to a model component file. The path can be a fileref.
Example TextFile=myfileref
BinaryFile=path-to-binary-file
specifies the destination path for a model component file that is a binary file. path-to-binary-file is a one-level pathname to a model component file that is not a text file. The pathname can be a fileref.
Example BinaryFile=myfileref
Name=alternateFileName
specifies a name for the model component file that you are retrieving. Use the Name argument when the name of the destination file does not match the name of the file in the SAS Model Manager repository. The Name argument is the filename within the SAS Model Manager repository. If Name is not specified, the filename that is registered in the SAS Model Manager repository is the name of the file.
Example Name=score.sas
Trace=ON | OFF
specifies whether to supply verbose trace messages to the SAS log.
Default OFF
Example Trace=on

Details

Use the %MM_GetModelFile macro to retrieve a component file for a model that has been registered in the SAS Model Manager repository. You can retrieve a component file for any model by specifying the repository location of the model, or you can retrieve a component file for a champion model by specifying the version or project location in the SAS Model Manager repository.
The %MM_GetModelFile macro supports two types of files, text and binary files. Text files are ASCII files that contain character data. Binary files are files that are created by an application in a format that is specific to that application. If you are retrieving a text file, you must use the TextFile argument to specify the file. To avoid any unintentional character translations, all non-text files should be retrieved by using the BinaryFile argument.
SAS data files and SAS catalogs are binary files. Instead of using the BinaryFile argument to retrieve model component files to store as a SAS file or in a SAS catalog, you can use the SASDataFile and SASCatalog arguments respectively to specify the SAS location to store the file. The TextFile and BinaryFile arguments require a single SAS filename.
You can use the optional Name argument if you want to save the model component file with a different name from the name within the SAS Model Manager repository.
After you use the %MM_GetModelFile macro to copy a model component file to its new location, you can use the model component file for any purpose. For example, a simple application might use the %MM_GetModelFile macro to copy a registered model's score code file to the SAS WORK library. After the score code is copied to WORK, you can write SAS code that includes the score code in a SAS DATA step and is executed for experimental purposes.
If the destination file argument or the two-level SAS library reference name that is invoked in the macro uses the original filename, you do not need to specify the Name argument. In other words, the macro can use the SAS logical names to determine the name of the file in the model hierarchy. If the name of the destination file needs to be different from the name of the original file that was copied, use the Name argument to specify the new name for the model component file.

Example

/******************************************************/
/* Get the score code from a registered model and run */
/* it.                                                */
/******************************************************/

 Options NOmlogic NOmprint NOspool; 

/*****************************************************/
/* Get the SAS Model Manager 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_MulticastAddress=239.27.18.213;
 %let _MM_MulticastPort=8561;
 %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 model component file name and         */
/* destination.                                      */
/*****************************************************/

%let WorkPath = c:\myProject\2012;
 FILENAME dest '&WorkPath.\score.sas';

/*****************************************************/
/* Set to detect failure in case macro load fails.   */
/*****************************************************/

%let _MM_RC = -1;

/*****************************************************/
/* Get score code.                                   */
/*****************************************************/

%MM_GetModelFile(ModelId=//ModelManagerRepo/MMRoot/HomeEquity/HMEQ/2012/
DecisionTree, TextFile=dest);

/*****************************************************/
/* Display SAS Model Manager set macro variables.    */
/*****************************************************/

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

/*****************************************************/
/* Run score code. Sepcify the LIBNAME input path.   */
/*****************************************************/

LIBNAME input 'c:\mysascode\2012\DTree'; 
DATA score;
 set input.dTreeInp; 
 %include dest;
run;

%MM_GetURL Macro

Overview of the %MM_GetURL Macro

The MM_GetURL macro translates a specified SAS Model Manager UUID to a URL-style path address and sets the URL as the value of the _MM_URL and _MM_ResourcesURL macro variables.

Syntax

%MM_GetURL(UUID=UUID, <Trace=ON | OFF> );

Arguments

UUID=UUID
specifies the UUID of the object for which an URL is desired. A SAS Model Manager UUID is a 36-character string that identifies a single object in the SAS Model Manager model repository. The UUID argument is required.
Example UUID=cca1ab08-0a28-0e97-0051-0e3991080867
Trace=ON | OFF
specifies whether to supply verbose trace messages to the SAS log.
Default OFF
Example Trace=on

Details

The %MM_GetURL macro sets the value of the global macro variable _MM_URL to the URL of the specified SAS Model UUID.
If the UUId argument specifies a SAS Model Manager version or model, then the macro sets the global macro variable _MM_ResourcesURL to the URL of that object's associated Resources folder.
The %MM_GetURL macro does not set a value for the global macro variable, _MM_CID.

Example

/***************************************************/ 
/* Get the URL for the location of a model.         */
/****************************************************/

Options nomlogic nomprint nospool;

/****************************************************/ 
/* Get the SAS Model Manager 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_MulticastAddress=239.27.18.213;
%let _MM_MulticastPort=8561;
%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;

/***************************************************/ 
/* Set to detect failure in case macro load fails  */
/* and get the URL.                                */ 
/***************************************************/ 

%let _MM_RC= -1; 

%let target=aef7a78e-0a28-0e97-01c0-b8a0e5ba15c7; 
%MM_GetURL(UUid=&target,Trace=on); 
%put _MM_URL=&_MM_URL; 
%put _MM_ResourcesURL=&_MM_ResourcesURL;

%MM_Register Macro

Overview of the %MM_Register Macro

The %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 9.4 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 will be used as the value of the model Model Name property in the Project Tree.
Note This argument is required.
Description=model-description
specifies a description of the model, which will be used as the value of the model Description property in the Project Tree.
Label=model-label
specifies a model's label, which will be used as the value for the model Model Label property in the Project Tree. 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 will be used as the value for the model Subject property in the Project Tree. 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 Manager.
Algorithm=model-algorithm
specifies the model's computation algorithm, which will be used as the value of the model Algorithm property in the Project Tree.
Example Algorithm=Decision Tree
Function=model-function
specifies the model's function class, which will be used as the value for the model Function in the Project Tree. 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 will be used as the value of the model Modeler property in the Project Tree.
Tool=model-tool
specifies the modeling tool that was used to create the model, and that will be used as the value of the model Tool property in the Project Tree.
ToolVersion=model-tool-version
specifies the version of the tool that was used to create the model, and that will be used as the value of the model Tool Version property in the Project Tree.
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 Managers 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 in the Project Tree.
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 Syntax.

Examples

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

Options NOmlogic NOmprint NOspool;

/*****************************************************/
/*  Access and load the SAS Model Manager 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_MulticastAddress=239.27.18.213;
%let _MM_MulticastPort=8561;
%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/2012,
  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;
Registering a Generic Model
/**************************************************/
/* Registering a generic model.                      */
/*****************************************************/

Options nomlogic nomprint nospool;

/*****************************************************/
/* Load and access the SAS Model Manager 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_MulticastAddress=239.27.18.213;
%let _MM_MulticastPort=8561;
%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 SAS Model Manager        */
/******************************************************/

%let _MM_RC= -1; 

%MM_Register( 
  VersionId=
   //ModelManagerModelRepos/MMRoot/HomeEquity/HMEQ/2012,
  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 SAS Model Manager defined variables. */
/****************************************************/

Options nosource;
%PUT _MM_RC = &_MM_RC;
%PUT _MM_CId = &_MM_CId;
Options source;
Registering a PROC LOGISTIC OUTMODEL-Style Model
/*****************************************************/
/* Registering a PROC LOGISTIC OUTMODEL-style model. */
/*****************************************************/

Options nomlogic nomprint nospool;

/*****************************************************/
/* Load and access the SAS Model Manager 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_MulticastAddress=239.27.18.213;
%let _MM_MulticastPort=8561;
%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/2012,
  ScoreProgram=ProgCODE,
  LogisticOutModelTable=modelTbl.HMEQProcLogisticOutput,
  TrainingDataSamp=trainTbl.HMEQTraining,
  ModelName=HMEQLogisticOutmodel,
  Description=HMEQ Logistic OUTMODEL model added by macro,
  Trace=off);

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

%MM_RegisterByFolder Macro

Overview of the %MM_RegisterByFolder Macro

You use the %MM_RegisterByFolder macro to register one model or multiple models simultaneously to the SAS Model Manager model repository from a single directory. Each model is located in a subdirectory under the specified directory.

Syntax

%MM_RegisterByFolder (VersionId=path-to-version, ReportDir=path-to-folder,
<Trace=ON | OFF>);

Arguments

VersionId=path-to-version
specifies the SAS Model Manager UUID for an existing version in the SAS Model Manager model repository where the models are registered. path-to-version can be either a SAS Model Manager UUID or a SAS Model Manager version path.
Default the value of the _MM_CId macro variable
Note This argument is required.
Examples VersionId=b23327cb-0a29–0c76–011a-f7bb3d790340
VersionId=//ModelManagerDefaultRepo/MMRoot/DDHMEQ/HomeEquity/2012
ReportDir=path-to-folder
specifies the directory that contains the models to be registered.
Note This argument is required.
Trace=ON | OFF
specifies whether to supply verbose trace messages to the SAS log.
Default OFF
Example Trace=on

Details

You can register SAS Enterprise Miner models and SAS code models using the %MM_RegisterByFolder macro. The directory that you specify in the ReportDir argument is the parent folder. Each model has its own subfolder under the parent folder. Each type of model has requirements for the subfolder name and the contents of the subfolder:
Requirements for Registering Models in a Directory
Requirement Type
Enterprise Miner Models
SAS Code Models
Value of ReportDir
a valid directory name
a valid directory name
Model subdirectory name
the subdirectory name must be the name of the model
the subdirectory name must be the name of the model
Contents of the subdirectory
one file named miningResult.spk
Required files:
  • Modelmeta.xml
  • ModelInput.sas7bdat
  • Score.sas
Optional files:
  • ModelOutput.sas7bdat
  • ModelTarget.sas7bdat
Here is a description of the files that reside in the model subfolders:
miningResult.spk
The miningResult.spk file contains the model component files for a model that was created in SAS Enterprise Miner.
Modelmeta.xml
The Modelmeta.xml file uses XML to define the model component files and values for model properties.
ModelInput.sas7bdat
ModelInput.sas7bdat is a table that contains the model input variables. This file is used to create the model inputvar.xml file.
Score.sas
Score.sas contains the SAS score code, which can be a DATA step fragment or a SAS program.
ModelOutput.sas7bdat
ModelOutput.sas7bdat is a SAS data set that contains one or more model output variables.
ModelTarget.sas7bdat
ModelTarget.sas7bdat is a SAS data set that contains only the target variable.
The Modelmeta.xml file is an XML file that is a mapping of SAS Model Manager component filenames to user-defined component filenames. The <Model> element has two main sections:
  • <ModelMetadata> to define model properties
  • <FileList> to list the model component files. This list is comparable to the Files section of the Local Files window, which you use to import SAS code models in the SAS Model Manager window:
    Local Files Window
    For a list of files for each model type, see: Model Template Component Files.
    Within the <File> element, put the name of the file that is defined in the model template, in the <name> element. The contents of the <value> element is the filename under the model directory.
Here is an example Modelmeta.xml file for a classification model named HMEQ:
<?xml version="1.0" encoding="utf-8" ?>
<Model>
  <ModelMetadata>
    <name>hmeq</name>
    <description>Home Equity Model</description>
    <label>HMEQ</label>
    <algorithm></algorithm>
    <function>classification</function>
    <modeler></modeler>
    <tool>SASProc</tool>    
    <toolversion></toolversion>
    <subject></subject>
    <modelTemplate>Classification</ModelTemplate> 
    <scoreCodeType>SAS Program</scoreCodeType>
  </ModelMetadata>
  <FileList>
    <File>
       <name>score.sas</name>
       <value>myScoreFile.sas</value>
    </File> 
    <File>
       <name>modelinput.sas7bdat</name>
       <value>hmeqIn</value>
    </File> 
    <File>
       <name>modeloutput.sas7bdat</name>
       <value>hmeqOut</value>
    </File> 
    <File>
       <name>target.sas7bdat</name>
       <value>hmeqTar</value>
    </File> 
    <File>
       <name>inputvar.xml</name>
       <value></value>
    </File> 
    <File>
       <name>outputvar.xml</name>
       <value></value>
    </File> 
    <File>
       <name>targetvar.xml</name>
       <value></value>
    </File>
    <File>
       <name>train.sas7bdat</name>
       <value></value>
    </File> 
    <File>
       <name>Training.sas</name>
       <value></value>
    </File> 
    <File>
       <name>Training.log</name>
       <value></value>
    </File> 
    <File>
       <name>Training.lst</name>
       <value></value>
    </File> 
    <File>
       <name>outest.sas7bdat</name>
       <value></value>
    </File> 
    <File>
       <name>outmodel.sas7bdat</name>
       <value>om</value>
    </File> 
    <File>
       <name>Output.spk</name>
       <value></value>
    </File> 
    <File>
       <name>Format.sas7bcat</name>
       <value></value>
    </File> 
    <File>
       <name>Dataprep.sas</name>
       <value></value>
    </File> 
    <File>
       <name>Notes.txt</name>
       <value></value>
    </File> 
  </FileList>
</Model>

Example

Registering a Generic Model
/**************************************************/
/* Register a SAS Code Model By Folder                */
/*****************************************************/

Options nomlogic nomprint nospool;

/*****************************************************/
/* Load and access the SAS Model Manager 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_MulticastAddress=239.27.18.213;
%let _MM_MulticastPort=8561;
%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 folder.                */
/******************************************************/

%let modelFolder = c:\myModel;
%let hmeq2012 = //ModelManagerModelRepos/MMRoot/HomeEquity/HMEQ/2012;

/******************************************************/
/* Set to detect failure in case macro load fails     */
/* and register the models in SAS Model Manager.      */
/******************************************************/

%let _MM_RC= -1; 

%MM_RegisterByFolder(VersionId=&hmeq2012, ReportDir=&modelFolder, Trace=ON);

/****************************************************/
/* Display the SAS Model Manager-defined variables. */
/****************************************************/

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

%MM_CreateModelDataset Macro

Overview of the %MM_CreateModelDataset Macro

The %MM_CreateModelDataset macro creates a data set that contains information about models. SAS Model Manager can provide information for the champion mode or for all models that are in the specified model repository path. The repository path that you specify can be MMRoot, an organizational folder, a project, a version, or a model. The data set contains the information for models that exist under the specified path.

Syntax

%MM_CreateModelDataset (mDatasetName = name-of-data-set,
smmPath=folder-project-verion-or-model-path <isChampion=Y | N><, Trace=ON | OFF>);

Arguments

mDatasetName = name-of-data-set
specifies the name of the data set that the macro creates. The macro can be created in a data set that you specify by using a two-level name in the form libref.filename.
Default mDatasetName=work.models
smmPath=folder-project-version-or-model-path
specifies the path from which to obtain the model data. If the path is a folder, the data set contains model information for all models under that folder unless isChampion=Y. If isChampion=Y, the information that is returned is for only the champion model. If the path is a project, the data set contains model information for models under that project. If the path is a version, the data set contains model information for models under that version. If the path is a model, the data set contains model information for only that model.
Default MMRoot
isChampion=Y | N
specifies whether the information that is returned contains information for only the champion model or for all models.
Y specifies that the information that is returned is for only the champion model.
N specifies that the information that is returned is for all models.
Default Y
Trace=ON | OFF
specifies whether to supply verbose trace messages to the SAS log.
Default OFF
Example Trace=on

Details

By default, the %MM_CreateModelDataset returns data only about the champion model. If you want information about models other than the champion model, specify isChampion=N. The data set that is created contains these variables:
Algorithm Name ScoreCodeType
CreationDate Owner Template
Description ProductionDate TemplateFileName
ExpirationDate ProjectName Tool
FolderName ProjectPath UserProperties
Function ProjectState VersionName
ModelLabel ProjectURL VersionState
ModelUUID ProjectUUID isChampion
Modeler PublishedDate isDefaultVersion
ModificationDate RetiredDate isPublished

Example

Extracting Model Information
/*****************************************************/
/* Create a data set to contain model information    */
/*****************************************************/

Options nomlogic nomprint nospool;

/*****************************************************/
/* Load and access the SAS Model Manager 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_MulticastAddress=239.27.18.213;
%let _MM_MulticastPort=8561;
%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 data set and model     */ 
/* path.                                              */
/******************************************************/

libname modelDS 'c:\myModel\ModelInfo';
%let hmeq2012 = //ModelManagerModelRepos/MMRoot/HomeEquity/HMEQ/2012;

/******************************************************/
/* Set to detect failure in case macro load fails     */
/* and create the model data set.                     */
/******************************************************/

%let _MM_RC= -1; 

%MM_CreateModelDataset(mDatasetName=modelDS.models, 
    smmpath=//ModelManagerDefaultRepo/MMRoot/DDHMEQ/HMEQ/2012/Models/
              Regression,
    Trace=ON);

/****************************************************/
/* Display the SAS Model Manager-defined variables. */
/****************************************************/

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