%MM_GetModelFile Macro

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/2013/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/2013

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_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 model component file name and         */
/* destination.                                      */
/*****************************************************/

%let WorkPath = c:\myProject\2013;
 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/2013/
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\2013\DTree'; 
DATA score;
 set input.dTreeInp; 
 %include dest;
run;