Using Macros to Register Models Not Created by SAS Enterprise Miner

About the %AA_Model_Register Macro

You can use the %AAModel macro and the %AA_Model_Register macro to register the SAS Metadata Repository models that are not created by SAS Enterprise Miner. These models are created by SAS procedures and are supported by SAS Model Manager:
  • SAS/STAT item store models
  • High-performance models
  • PROC COUNTREG models
  • PROC SEVERITY models
If you do not want to register the model, you can create SAS package files (SPK) without registering the model. After the model is registered to the SAS Metadata Repository, you can import the model to SAS Model Manager using the import from SAS Metadata Repository method. If you create an SPK file, you would import the model using the import from SAS Model Package File method.
The %AAModel macro is an autocall macro that loads the %AA_Model_Register macro. This macro must be submitted before you submit the %AA_Model_Register macro.
You specify these types of arguments in the %AA_Model_Register macro:
  • The model identification argument’s name. You must also describe a model and identify a SAS/STAT item store.
  • Action arguments specify whether to create an SPK file and whether to register the model in the SAS Metadata Repository.
  • You specify model component arguments when a SAS/STAT procedure does not create an item store, if a model is created using high performance analytic procedures, or if you are registering PROC COUNTREG or PROC SEVERITY models. The model component arguments identify the train data set, the model level, and the score code file. The arguments also identify whether the score code is only DATA step code or a SAS program that includes DATA step code, macros, procedures.
  • The Lookup=Select option if a SAS/STAT model’s input variable includes non-latin1 characters. This option ensures the generation of correct score code.
  • Other options are available to add information to the model or to specify whether to keep or delete the data sets that the macro produces.
For more information, see %AA_Model_Register Autocall Macro.
When you are registering the model to the SAS Metadata Repository, you can specify the metadata server connection system options before you run the %AAModel and %AAModel_Register macros. If these options are not specified, dialog boxes appear to prompt you for the information. Here is a sample OPTIONS statement that specifies these options:
options metaPort=8561 
        metaServer=server-address
        metaRepository=Foundation
        metaUser=user-ID
        metaPass=password;
These SAS/STAT procedures can create an item store using the STORE statement:
Procedure
Item Store Restrictions
GENMOD
Training code is not included
GLIMMIX
Training code is not included
GLM
Training code is not included
GLMSELECT
Fit statistics are not included
LOGISTIC
None
MIXED
Training code is not included
REG
Training code or fit statistics are not included
If you want to retrain models using SAS Model Manager and if the procedure item store does not include training code, you must create the SAS training code before you run the %AA_Model_Register macro.
Note: Item store restrictions have not been evaluated for other SAS/STAT procedures that have a STORE statement. Using the %AA_Model_Register macro might cause undesirable results.

Register a Model in the SAS Metadata Repository Using a SAS/STAT Item Store

After you run a SAS/STAT procedure using the STORE statement, you use the %AA_Model_Register macro to register the model to the SAS Metadata Repository.
In the following example program, the PROC LOGISTICS STORE statement creates an item store in work.logisticStore. The %AA_Model_Register macro uses the item store in work.logisticStore to create the register file.
/* PROC LOGISTIC specifies the STORE statement to create an item store. *
/
proc logistic data=sampsio.hmeq;
   class job;
   model bad = loan value job;
   store work.logisticStore;
run;

/* Set up the meta data connection system options. */

options metaPort=8561 
      metaServer=server-address
      metaRepository=Foundation
      metaUser=user-ID
      metaPass=password;

/* Load the macros. */

%aamodel;

/* Register the model in the SAS Metadata Repository. */

%aa_model_register(modelname=LogisticTest, 
                   modeldesc=%nrbquote(Logistic Test),
                   itemstore=work.logisticstore,
                   register=Y,
                   mrPath=%NRBQUOTE(/User Folders/user-ID/My Folder/),
                   spk=N,
                   spkfolder=c:\temp\,
                   data=sampsio.hmeq)
                   ;
The model can now be imported to SAS Model Manager using the import from SAS Metadata Repository method.

Create a SAS Package File Using a SAS/STAT Item Store

To create a SAS package (SPK) file without registering it to the SAS Metadata Repository, you specify the Register=Y, SPK=Y, and the SPKFolder= arguments. This example shows these modifications using the previous example:
/* PROC LOGISTIC specifies the STORE statement to create an item store. *

proc logistic data=sampsio.hmeq;
   class job;
   model bad = loan value job;
  store work.logisticStore;
run;

/* Set up the meta data connection system options. */

options metaPort=8561 
      metaServer=server-address
      metaRepository=Foundation
      metaUser=user-ID
      metaPass=password;

/* Load the macros. */

%aamodel;

/* Create an SPK file; do not register the model in the SAS Metadata Repository. */

%aa_model_register(modelname=LogisticTest, 
                   modeldesc=%nrbquote(Logistic Test),
                   itemstore=work.logisticstore,
                   register=N,
                   spk=Y,
                   spkfolder=c:\temp\,
                   data=sampsio.hmeq)
                   ;
The macro creates a folder for the model in the c:\temp folder. The folder name is the UUID of the model. The name of the SPK file is miningResults.spk. The SPK file can be imported to SAS Model Manager using the import from SAS Model Package File method.

Register a Model in the SAS Metadata Repository Using Model Component Files

If you do not have an item store, or if you have the information and files that you need for a model, you can use the %AA_Model_Register macro to register the model in the SAS Metadata Repository. In addition to the macro’s model identification arguments and the action arguments, you can use these arguments to register the model:
  • Data=training-data-set-name
  • Level=Binary | Ordinal | Nominal | Interval
  • ScoreCodeFile=filename
  • ScoreCodeFormat=Datastep | Program
  • Target=target-variable
The following SAS program uses model component arguments to register the model to the SAS Metadata Repository. Other arguments identify the mining function and mining algorithm.
/* Train high performance model */

proc hplogistic data=gplib.hmeqid; class job reason;
   id value;
   class bad ;
   model bad = clage clno debtinc delinq derog mortdue job reason;
   output out=gplib.hpregid_score pred;
   code file='c:\temp\score.sas' ;
run;  

/* Set up metadata connections */

options metaPort=8561 
        metaServer=server-address 
        metaRepository=Foundation
        metaUser=user-ID
        metaPass=password;

/* Load the macros. */

%aamodel;

/* Register the model in the SAS Metadata Repository */

%aa_model_register
   (modelname=Model1, 
    modeldesc=%nrbquote(First Model for registration),
    register=Y, 
    mrPath=%NRBQUOTE(/User Folders/user-ID/My Folder/),
    spk=N, 
    spkfolder=c:\temp\, 
    data=sampsio.hmeq,
    target=bad,
    level=BINARY,
    miningfunction=Classification,
    miningalgorithm=Regression,
    scorecodefile=c:\temp\score.sas)
;
The model can now be imported to SAS Model Manager using the import from SAS Metadata Repository method.