Using the Model Management Access Macros

Global Macro Variables

Your SAS program and SAS Decision Manager use global macro variables to pass information about the SAS environment and the SAS Decision Manager model repository to the access macros. Some macros set these global macro variables. You can set any of these global macro variables in your SAS program. At the end of each macro execution, the global macro variable _MM_RC is set to a number that indicates either that the macro executed successfully or that there was an error.
Note: As part of a recent SAS Model Manager 14.1 hot fix (V85008 or later), the _MM_Service_Registry_URL macro variable is no longer used. If your SAS program contains this macro variable it will be ignored. For a list of the latest hot fixes, see SAS Model Manager 14.1 Hot Fixes.
Here is a description of the Model Management global macro variables:
_MM_CId
contains the name of the current object identifier. _MM_CId is either the URL or the SAS Decision Manager path to the object in the model repository. You can use the %MM_GetURL to obtain a URL for any object in the model repository.
The %MM_Register macro sets _MM_CId to contain the identifier for the registered model. The %MM_AddModelFile macros sets _MM_CId to the identifier for the model to which the file was added.
_MM_RC
contains one of the following return codes after processing a Model Management access macro:
_MM_RC
Return Value
Access Macro
Status
0
All OK
1
Macro parameter error
_MM_ResourceURL
contains the URL of the Resources folder. the _MM_Resource URL is set by the %MM_GetURL macro when the macro returns a version URL in the _MM_URL global macro variable.
_MM_URL
contains a URL for a SAS Decision Manager object. The %MM_GetURL macro returns a URL in the _MM_URL global macro variable.
_MM_User
contains the name of a SAS Decision Manager user on the server that is specified by the _MM_MulticastAddress global macro variable.
Default: the value of SAS automatic macro variable &SYSUSERID.
_MM_Password
contains a password for the SAS Decision Manager user. If you do not encode the password using the PWENCODE procedure, the password is printed in the SAS log.
Note: The _MM_User and _MM_Password access macros need to be specified only if you want to access the SAS Content Server with FILENAME or LIBNAME statements.
For a description of these macro variables as well as their default values, see Global Macro Variables.
If you are running macros in a SAS session that requires a connection to the SAS Metadata Server, you must specify the metadata connection system options before you run the macros. If these options are not specified, you will be prompted for the information. If you are running the macros in batch mode, you must include the metadata connection system options. Otherwise, you will receive a failure message. For more information, see Setting Metadata Connection System Options.

See Also

Accessing the Macros

Before you can use the access macros, your SAS program must access the catalog where the macros are located, and load the macros into memory. Here is example code to do this:
/*******************************************/
/* Specify the macro code location         */
/*******************************************/ 

Filename MMAccess catalog "sashelp.modelmgr.accessmacros.source"; 

/*******************************************/
/* Load the Access macros                  */
/*******************************************/

%include MMAccess; 
/*******************************************/
/* Unassign the filename                   */
/*******************************************/
Filename MMAccess;

Identifying SAS Decision Manager Model Repository Objects

The access macros use an identifier to specify a unique object such as the version or a model, in the SAS Decision Manager model repository. The identifier can be in the form of a Universally Unique Identifier (UUID) or a SAS Decision Manager path.
  • A UUID is a case sensitive, 36-character string that uniquely identifies the repository object. An example UUID is cca1ab08-0a28-0e97-0051-0e3991080867.
    If you need to find the UUID or the exact SAS Decision Manager path for an object, you can look it up in SAS Decision Manager on the System tab of the Models Properties page. The UUID and path values are listed there.
  • The format for a SAS Decision Manager path is //repositoryID/MMRoot/folder/project/version/Models/model.
    The name of repositoryID is defined during installation. The names of the folder, project, version, and model that follow in the path are user-defined. SAS Decision Manager path specifications always use the forward slash character (/) as a separator.
    For example, a version path might look like //MMModelRepository/MMRoot/HomeEquity/HMEQ/1.0.
You use the _MM_CId global macro variable to pass a model repository identifier to an access macro. For more information, see _MM_CId.

Identifying Files Used by Access Macros

All Model Management access macros that accept SAS file references require the file references to point to a single physical file. File references in the form libref.filename must resolve to a single physical file. Specific logical library references in the form libref must resolve to a directory or a folder.
Concatenated library references cannot be used.
Here is a list of libraries to which you must assign a libref in your SAS programs:
  • the directory that contains your model files
  • the directory that contains the training data
  • the directory that contains your input, output, and target data sets
Model Management access macros use the libref SMMMODEL to access model component files, as in this example:
libname smmmodel "c:\myModel\HMEQ\scorecode";
You can define the libref SMMMODEL at the beginning of your SAS program and use it to access model component files in any of the Model Management access macros that your program executes.
Here is a list of files that you can identify with a fileref in your SAS programs:
  • a catalog fileref to the Model Management access macro code
  • the source path and filename for a single file to be registered by the %MM_AddModelFile macro
  • the source path and filename for a SAS Enterprise Miner package file to be registered by the %MM_Register macro
  • the destination path and filename for the %MM_GetModelFile macro

Required Tables

Whether you use SAS Decision Manager or the access macros, SAS Decision Manager must know the model input variables, the output variables, and the target variables to register a model. SAS Decision Manager uses an XML file to describe each of these types of files. Before you can register a SAS code model, you must create a SAS data set that represents the input, output, and target variables:
  • The model input table contains the variables that are used as input by the model. During model registration, SAS Decision Manager uses this table to create the inputvar.xml file.
  • The model output table is a table whose variables contain the model output values. During model registration, SAS Decision Manager uses this table to create the outputvar.xml file.
  • The model target variable table is a table whose one variable is the target variable that is used in the training data. During model registration, SAS Decision Manager uses this file to create the targetvar.xml file.
Each of these tables can be a one-row table. The tables' purpose is to define and describe the variables that are used by the model.
You can create each of these tables using the training data that you used to train your model. The following example SAS program uses the training data to create all three tables:
/********************************************************/
/*  Set the location for the model tables               */
/********************************************************/

libname hmeqtabl "c:\myModel\hmeq\tables";

/*********************************************************/
/*  DATA step to create the target variable table.       */
/*  Because there is only one target variable, keep only */
/*  that variable.                                       */
/*********************************************************/

data hmeqtabl.target;
   set hmeqtabl.training(obs=1);
   keep bad;
run;

/*********************************************************/
/*  DATA step to create the input variable table.        */
/*  Keep only the variables used for input by the model. */
/*********************************************************/

data hmeqtabl.invars;
   set hmeqtabl.training (obs=1);
   keep debtinc delinq derog job loan mortdue ninq reason value yoj;
run;

/*********************************************************/
/*  DATA step to create the output variable table.       */
/*  Keep only the variables used for output by the model.*/
/*  Include the score code to get the output variables.  */
/*********************************************************/

data hmeqtabl.outvars;
   set hmeqtabl.training;
   %include "c:\myModel\hmeq\score.sas"   keep f_bad i_bad p_0 p_1;
run;

Last updated: February 22, 2017