%MM_AddModelFile Macro

Add model component files to an existing SAS Model Manager model.

Syntax

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

Arguments

ModelId=path-to-model

specifies an identifier of the model in the SAS Model Manager model repository. The identifier specifies the location in the SAS Model Manager model 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/1.0/Models/HMEQ%20Loan%20Project
ModelId=//ModelManagerDefaultRepo/MMRoot/DDHMEQ/HomeEquity/1.0/Models/HMEQ Loan Project

SASDataFile=SAS-data-set-reference

specifies the location of the SAS data set to add to a model in the SAS Model Manager model repository. SAS-data-set-reference must be a two-level SAS name in the form libref.filename.

Example SASDataFile=mysaslib.hmeqloan

SASCatalog=SAS-catalog-reference

specifies the location of a SAS catalog that includes of one or more SAS code model component files to add to a model in the SAS Model Manager repository. SAS-catalog-reference must be a two-level SAS name in the form libref.catalog. Use the SASCatalog argument to add the catalog to a model.

Example SASCatalog=mylib.modelinput

TextFile=fileref-to-text-file

specifies the file reference to the location of a SAS code model component file that is an ASCII text file. fileref-to-text-file is a one-level SAS reference to a model component file.

Example TextFile=inputxml

BinaryFile=fileref-to-binary-file

specifies the file reference to the location of a SAS code model component file that is a binary file. fileref-to-binary-file is a one-level SAS reference 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 model repository. After files have been added, you can view the files in the Models page of a project.
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 Model Management macro code.            */
/***************************************************/
  
Filename MMAccess catalog 'SASHELP.modelmgr.AccessMacros.source';
%include MMAccess;

/***************************************************/
/* 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/1.0/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/1.0/hmeqDecTree1,
  TextFile=tcode,
  Trace=on);
Last updated: February 14, 2017