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.
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_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.
_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
2
Macro parameter processing error
3
Repository login failed
4
Repository operation failed
5
Generic critical Java error
6
Generic DATA step 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_Service_Registry_URL
contains the URL for a SAS environment file that defines the SAS environment.
_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.
When you use the access macros, the macros need to know the following information:
  • how to access the SAS environment XML file and environment name
  • a user and password for processing requests to SAS Decision Manager
  • the URL or path to the SAS Decision Manager model repository
Make sure that your SAS program defines values for these macro variables when you use the access macros:
  • _MM_Service_Registry_URL
  • _MM_User
  • _MM_Password
To secure the Model Manager user password, encode the password using the PWENCODE procedure and save it in a file on the network. You can then use a fileref to access the password file and a DATA step to assign the password to the _MM_Password global macro variable. For more information, see Encoding SAS Decision Manager User Passwords.
For a description of these macro variables as well as their default values, see Global Macro Variables.
Here is a code example that uses the four macro variables to describe how to the access to the server for the Web Infrastructure Platform.
Filename pwfile  “my-network-drive\pwfile”;

%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;

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; 

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 Universal 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/2013.
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;