Using Macros to Register SAS/STAT Item Store and High Performance Models

About the %AA_MODEL_REGISTER Macro

You can use the %AAMODEL macro and the %AA_MODEL_REGISTER macro to register to the SAS Metadata Repository SAS/STAT item store models and high performance models that are not created with SAS Enterprise Miner. 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 or if a model is created using high performance analytic procedures . 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.
  • 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.