%MM_RegisterByFolder Macro

Register one model or multiple models simultaneously to the model repository from a single directory. Each model is located in a subdirectory under the specified directory.

Syntax

%MM_RegisterByFolder (VersionId=path-to-version, ReportDir=path-to-folder,
<Trace=ON | OFF>);

Arguments

VersionId=path-to-version

specifies the SAS Model Manager UUID for an existing version in the SAS Model Manager model repository where the models are registered. path-to-version can be either a SAS Model Manager UUID or a version path.

Default the value of the _MM_CId macro variable
Note This argument is required.
Examples VersionId=b23327cb-0a29–0c76–011a-f7bb3d790340
VersionId=//ModelManagerDefaultRepo/MMRoot/DDHMEQ/HomeEquity/2013

ReportDir=path-to-folder

specifies the directory that contains the models to be registered.

Note This argument is required.

Trace=ON | OFF

specifies whether to supply verbose trace messages to the SAS log.

Default OFF
Example Trace=on

Details

You can register SAS Enterprise Miner models and SAS code models using the %MM_RegisterByFolder macro. The directory that you specify in the ReportDir argument is the parent folder. Each model has its own subfolder under the parent folder. Each type of model has requirements for the subfolder name and the contents of the subfolder:
Requirements for Registering Models in a Directory
Requirement Type
Enterprise Miner Models
SAS Code Models
Value of ReportDir
a valid directory name
a valid directory name
Model subdirectory name
the subdirectory name must be the name of the model
the subdirectory name must be the name of the model
Contents of the subdirectory
one file named miningResult.spk
Required files:
  • Modelmeta.xml
  • ModelInput.sas7bdat
  • Score.sas
Optional files:
  • ModelOutput.sas7bdat
  • ModelTarget.sas7bdat
Here is a description of the files that reside in the model subfolders:
miningResult.spk
The miningResult.spk file contains the model component files for a model that was created in SAS Enterprise Miner.
Modelmeta.xml
The Modelmeta.xml file uses XML to define the model component files and values for model properties.
ModelInput.sas7bdat
ModelInput.sas7bdat is a table that contains the model input variables. This file is used to create the model inputvar.xml file.
Score.sas
Score.sas contains the SAS score code, which can be a DATA step fragment or a SAS program.
ModelOutput.sas7bdat
ModelOutput.sas7bdat is a SAS data set that contains one or more model output variables.
ModelTarget.sas7bdat
ModelTarget.sas7bdat is a SAS data set that contains only the target variable.
The Modelmeta.xml file is an XML file that is a mapping of SAS Model Manager component filenames to user-defined component filenames. The <Model> element has two main sections:
  • <ModelMetadata> to define model properties
  • <FileList> to list the model component files. This list is comparable to the Files section of the Local Files window, which you use to import SAS code models.
    For a list of files for each model type, see Model Template Component Files.
    Within the <File> element, put the name of the file that is defined in the model template, in the <name> element. The contents of the <value> element is the filename under the model directory.
Here is an example Modelmeta.xml file for a classification model named HMEQ:
<?xml version="1.0" encoding="utf-8" ?>
<Model>
  <ModelMetadata>
    <name>hmeq</name>
    <description>Home Equity Model</description>
    <label>HMEQ</label>
    <algorithm></algorithm>
    <function>classification</function>
    <modeler></modeler>
    <tool>SASProc</tool>    
    <toolversion></toolversion>
    <subject></subject>
    <modelTemplate>Classification</ModelTemplate> 
    <scoreCodeType>SAS Program</scoreCodeType>
  </ModelMetadata>
  <FileList>
    <File>
       <name>score.sas</name>
       <value>myScoreFile.sas</value>
    </File> 
    <File>
       <name>modelinput.sas7bdat</name>
       <value>hmeqIn</value>
    </File> 
    <File>
       <name>modeloutput.sas7bdat</name>
       <value>hmeqOut</value>
    </File> 
    <File>
       <name>target.sas7bdat</name>
       <value>hmeqTar</value>
    </File> 
    <File>
       <name>inputvar.xml</name>
       <value></value>
    </File> 
    <File>
       <name>outputvar.xml</name>
       <value></value>
    </File> 
    <File>
       <name>targetvar.xml</name>
       <value></value>
    </File>
    <File>
       <name>train.sas7bdat</name>
       <value></value>
    </File> 
    <File>
       <name>Training.sas</name>
       <value></value>
    </File> 
    <File>
       <name>Training.log</name>
       <value></value>
    </File> 
    <File>
       <name>Training.lst</name>
       <value></value>
    </File> 
    <File>
       <name>outest.sas7bdat</name>
       <value></value>
    </File> 
    <File>
       <name>outmodel.sas7bdat</name>
       <value>om</value>
    </File> 
    <File>
       <name>Output.spk</name>
       <value></value>
    </File> 
    <File>
       <name>Format.sas7bcat</name>
       <value></value>
    </File> 
    <File>
       <name>Dataprep.sas</name>
       <value></value>
    </File> 
    <File>
       <name>Notes.txt</name>
       <value></value>
    </File> 
  </FileList>
</Model>

Example

Registering a Generic Model
/**************************************************/
/* Register a SAS Code Model By Folder                */
/*****************************************************/

Options nomlogic nomprint nospool;

/*****************************************************/
/* Load and access the Model Management 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 location of the folder.                */
/******************************************************/

%let modelFolder = c:\myModel;
%let hmeq2013 = //ModelManagerModelRepos/MMRoot/HomeEquity/HMEQ/2013;

/******************************************************/
/* Set to detect failure in case macro load fails     */
/* and register the models in the model repository.      */
/******************************************************/

%let _MM_RC= -1; 

%MM_RegisterByFolder(VersionId=&hmeq2013, ReportDir=&modelFolder, Trace=ON);

/****************************************************/
/* Display the defined variables. */
/****************************************************/

Options nosource;
%PUT _MM_RC = &_MM_RC;
Options source;