%MM_AddModelFile Macro

Add model component files to an existing SAS Decision 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 an identifier of the model in the SAS Decision Manager model repository. The identifier specifies the location in the SAS Decision Manager model repository where the file is to be added. path-to-model can be either a SAS Decision Manager UUID or a SAS Decision 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/2013/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 Decision Manager model 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 Decision 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 Decision 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 Decision 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 Decision 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 Decision 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;

/* 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=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/2013/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/2013/hmeqDecTree1,
  TextFile=tcode,
  Trace=on);