Model Templates

What is a Model Template?

Models that you import into SAS Decision Manager are associated with a specific model template. A model template has properties and component files that define a type of model. SAS Decision Manager processes four types of models: analytical, classification, prediction, and segmentation. You can create your own model template if your model requires files other than those named in the SAS Decision Manager templates.
A model template is an XML file that has three sections. The General section names and describes the model template. The Properties section provides properties to name the model algorithm, the modeler, and a model label. The Files section contains the component files that can be used in the template for that model function type. You associate your component file with the appropriate model template component file. Your component file filenames do not need to be the same name as the filenames in the model template.
Model templates provide you with a way to define metadata about your own model. Most users do not need to write model templates because SAS Decision Manager delivers a list of model templates that handle SAS Enterprise Miner models as well as analytical, prediction, classification, and segmentation models. However, you can write your own model templates if the model templates that are provided do not satisfy your requirements. For more information, see Manage Templates.

Model Types

SAS Decision Manager provides model templates for analytical, classification, prediction, and segmentation models.
Model Type
Description
Analytical
The Analytical model template is the most generic template that is designed for models whose model function does not fall in the prediction, classification, and segmentation category.
Classification
You use the Classification model template if your model is a prediction model that has a categorical, ordinal, or binary target, or if your model is a LOGISTIC procedure regression model. Examples of classification models are models that might classify a loan applicant as Approved or Not Approved, or models that might assess a potential customer's risk of default as Low, Medium, or High.
Prediction
The Prediction model template is used for predictive models. Predictive models declare in advance the outcome of an interval target. A model that assigns a numeric credit score to an applicant is an example of a prediction model.
Segmentation
The Segmentation model template is used for segmentation or cluster models that are written in SAS code. Segmentation models are unsupervised models that have no target variable. A segmentation or cluster model is designed to identify and form segments, or clusters, of individuals or observations that share some affinity for an attribute of interest. The output from a segmentation model is a set of cluster IDs. R models cannot have segmentation model function.

Model Template Component Files

Here is a list of the component files that are associated with the model templates:
IGN_STATS.csv
The value of IGN_STAT.csv is the name of a file whose values are separated by commas, and whose values are bin definitions for input variables. This is a component file that is generated by SAS Enterprise Miner for a scorecard model and is not needed for SAS code models.
EMPublishScore.sas
The value of EMPublishScore.sas is the name of a SAS code file that is used to change input variables into bins and is a component of a SAS Enterprise Miner scorecard model. This file is needed to define a performance task. This file is not needed for SAS code models.
Scorecard_GainsTable.csv
This file includes the bin score definitions and is not used in reporting by SAS Decision Manager. The file's content can be viewed by users.
score.sas
The value of score.sas is the name of a filename for the SAS score code for the model.
For R models, this file transforms a scoring data set to an R data frame.
The score.sas file is DATA step score code and is used as input by the SAS Scoring Accelerator when publishing a model to a database. When you are using the scoring function publish method, some SAS language elements and syntax are not supported when you create or modify your score code. Only the SAS language elements and syntax that are required to run critical data transformations and model scoring functions are available. If you use a statement or function that is not supported, an error occurs and your model is not published to the database. For more information, see Considerations When Creating or Modifying DATA Step Score Code in SAS In-Database Products: User's Guide.
modelinput.sas7bdat
The value of modelinput.sas7bdat is the name of a sample data set that is used to create an inputvar.xml file for the model if one does not exist. When no inputvar.xml file exists for the model, SAS Decision Manager creates the inputvar.xml file using the variable name and attributes in the modelinput.sas7bdat file. Observation values are not used. Therefore, the sample data set can have no observations or it can have any number of observations. If an inputvar.xml is specified in the model template, modelinput.sas7bdat is ignored.
When you import a SAS code model, the data set that you used to test your score code can be used as the value for the modelinput.sas7bdat file.
Note: If the same variables appear in your modelinput.sas7bdat file and your modeloutput.sas7bdat file, when you import the model, SAS Decision Manager removes the duplicate variables in the outputvar.xml file.
modeloutput.sas7bdat
The value of modeloutput.sas7bdat is the name of a sample data set that is used to create an outputvar.xml file for the model if one does not exist. When no outputvar.xml file exists for the model, SAS Decision Manager creates the outputvar.xml file using the variable name and attributes in the modeloutput.sas7bdat file. Observation values are not used. Therefore, the sample data set can have no observations or it can have any number of observations. If an outputvar.xml is specified in the model template, modeloutput.sas7bdat is ignored.
You can create a modeloutput.sas7bdat file by running the score.sas file against the modelinput.sas7bdat file.
target.sas7bdat
The value of target.sas7bdat is the name of a sample data set that is used to create a targetvar.xml file for the model if one does not exist. When no targetvar.xml file exists for the model, SAS Decision Manager creates the targetvar.xml file using the variable name and attributes in the target.sas7bdat file. Data set values are not used. Therefore, the sample data set can have no observations or it can have any number of observations. If a targetvar.xml file is specified in the model template, target.sas7bdat is ignored.
You can create a target.sas7bdat file by creating a data set that keeps only the target variables that are taken from the training data set, as in this example:
data mydir.target;
    set mydir.myModelTraining (obs-1)
    keep P_BAD;
run;
inputvar.xml
The value of inputvar.xml is the name of an XML file that defines the model input variables. When your model template includes a file for modelinput.sas7bdat, SAS Decision Manager creates the model inputvar.xml file. Otherwise, you must create the XML file.
The following XML file is a sample inputvar.xml file that has one variable, CLAGE. You can use this model to create an inputvar.xml file that contains a VARIABLE element for each model input variable.
<?xml version="1.0" encoding="utf-8"?>
<TABLE>
   <VARIABLE>
		 <NAME>CLAGE</NAME>
		 <TYPE>N</TYPE>
		 <LENGTH>8</LENGTH>
		 <LABEL Missing=""/>
		 <FORMAT Missing=""/>
		 <LEVEL>INTERVAL</LEVEL>
		 <ROLE>INPUT</ROLE>
		</VARIABLE>
   </TABLE>
NAME
specifies the variable name.
TYPE
specifies the variable type. Valid values are N for numeric variables and C for character variables.
LENGTH
specifies the length of the variable.
LABEL Missing=""
specifies the character to use for missing values. The default character is a blank space.
FORMAT Missing=""
specifies a SAS format to format the variable.
LEVEL
specify either NOMINAL, ORDINAL, INTERVAL, or BINARY.
ROLE
specify INPUT for input variables.
outputvar.xml
The value of outputvar.xml is the name of an XML file that defines the model output variables. When your model template includes a file for modeloutput.sas7bdat, SAS Decision Manager creates the model outputvar.xml file. Otherwise, you must create the XML file.
The following XML file is a sample outputvar.xml file that has one variable, I_BAD. You can use this model to create an outputvar.xml file that contains a VARIABLE element for each model output variable.
<?xml version="1.0" encoding="utf-8"?>
<TABLE>
   <VARIABLE>
		 <NAME>I_BAD</NAME>
		 <TYPE>C</TYPE>
		 <LENGTH>12</LENGTH>
		 <LABEL>Into: BAD</LABEL>
		 <FORMAT Missing=""/>
		 <LEVEL>NOMINAL</LEVEL>
		 <ROLE>CLASSIFICATION</ROLE>
   </VARIABLE>
 </TABLE>
NAME
specifies the variable name.
TYPE
specifies the variable type. Valid values are N for numeric variables and C for character variables.
LENGTH
specifies the length of the variable.
LABEL Missing=""
specifies a label for the output variable.
FORMAT Missing=""
specifies a SAS format to format the variable.
LEVEL
specify either NOMINAL, ORDINAL, INTERVAL, or BINARY.
ROLE
specify the type of model output. Valid values are CLASSIFICATION, PREDICT, SEGMENT, and ASSESS.
targetvar.xml
The value of targetvar.xml is the name of an XML file that defines the model target variables. When your model template includes a file for target.sas7bdat, SAS SAS Decision Manager creates the targetvar.xml file. Otherwise, you must create the XML file.
The following XML file is a sample targetvar.xml file that has one variable, I_BAD. You can use this model to create an outputvar.xml file that contains a VARIABLE element for each model output variable.
<?xml version="1.0" encoding="utf-8"?>
<TABLE>
   <VARIABLE>
		 <NAME>BAD</NAME>
		 <TYPE>N</TYPE>
		 <LENGTH>8</LENGTH>
		 <LABEL>Missing=””/>
		 <FORMAT Missing=""/>
		 <LEVEL>BINARY</LEVEL>
		 <ROLE>TARGET</ROLE>
  </VARIABLE>
 </TABLE>
NAME
specifies the variable name.
TYPE
specifies the variable type. Valid values are N for numeric variables and C for character variables.
LENGTH
specifies the length of the variable.
LABEL Missing=""
specifies a label for the target variable.
FORMAT Missing=""
specifies a SAS format to format the variable.
LEVEL
specify either NOMINAL, ORDINAL, INTERVAL, or BINARY.
ROLE
specify TARGET.
smmpostcode.sas
SAS Decision Manager creates this file to document the mapping that the user specified between the model variables and the project variables.
trainingvariables.csv
This optional file contains a list of the training variables.
training.sas
This file is the optional SAS code that was used to train the model that you are importing. If at some time, SAS Decision Manager reporting utilities detect a shift in the distribution of model input data values or a drift in the model's predictive capabilities, the training.sas code can be used to retrain the model on the newer data. If it is not available at import time, the training.sas code can be added at a later point using the Add Local Files feature.
training.log
This file is the optional log file that was produced when the model that you are importing was trained. The information in the optional SAS training log can be helpful if the model must be retrained in the future.
training.lst
This file is the optional text output that is produced when the training.sas code is run. The information in the optional SAS training.lst table can be helpful if the model must be retrained in the future.
outest.sas7bdat
This data set contains output estimate parameters that are produced by a few SAS procedures, including the LOGISTIC procedure.
outmodel.sas7bdat
This data set contains output data that is produced by a few SAS procedures, including the LOGISTIC procedure and the ARBORETUM procedure. It contains complete information for later scoring by the same SAS procedure using the SCORE statement.
output.spk
This file is the SAS package file that contains the SPK collection of model component files.
miningresult.spk
This is a SAS package file that stores detailed information about SAS Enterprise Miner nodes in the flow from which the model is created and the detailed information for SAS/STAT item store models.
layout.xml
This optional file contains information about the SAS Enterprise Miner diagram topology.
format.sas7bcat
This file is the optional SAS formats catalog file that contains the user-defined formats for their training data. If the model that you are importing does not use a user-defined format, then you do not need to import a format.sas7bcat catalog file.
dataprep.sas
This file contains optional SAS code that is intended to be executed before each run of score code.
batch.sas
This file is created by SAS Enterprise Miner and is used for model retraining by SAS Decision Manager.
pmml.xml
This file contains score code in PMML format.
training.r
This is an optional R script file that is used to retrain R models in SAS Decision Manager.
outmodel.rda
SAS Decision Manager requires this file to save the output parameter estimate for R models.
score.r
This file is an R script that is used to predict new data.
fitstats.xml
This file is created by SAS Enterprise Miner and contains the basic Fit Statistics for the model.
HPDMForest_VARIMPORT.csv
This CSV file contains the variable importance data for a PROC HPFOREST model.
HPDMForest_ITERATION.csv
This CSV file contains statistics across each iteration of a PROC HPFOREST model.
OUTMDLFILE.bin
This is a binary file that contains the PROC HPFOREST model information to be used for scoring.
For information about preparing R model component files, see R Model Support.

Model Template Properties

Template Properties

Here is a list of the general properties that define the model template.
Property Name
Description
Name
Identifies the name of the template. This property is required. The characters @ \ / * % # & $ ( ) ! ? < > ^ + ~ ` = { } [ ] | ; : ‘ " cannot be used in the name.
Description
Specifies user-defined information about the template.
Type
Specifies the type of the model. SAS Decision Manager supports the following model types:
Analytical Model
specifies the type of model that is associated with the Analytical model function.
Classification Model
specifies the type of model that is associated with the Classification model function.
Prediction Model
specifies the type of model that is associated with the Prediction model function.
Clustering Model
specifies the type of model that is associated with the Segmentation model function.
Tool
Specifies a text value that describes which tool is used to produce this type of model.
Validate
Indicates that SAS Decision Manager verifies that all of the required files are present when users try to import a model. If validation fails, the model will not be successfully imported.
Display name
Specifies a text value that is displayed as the name of the model template.
Score code type
Specifies whether the imported model score code runs by using a DATA Step fragment, SAS Program code, or PMML.

File List Properties

Here is a list of the File List properties that specify the files that are contained in a model.
Property Name
Definition
Name
Identifies the name of the file. This property is required.
Description
Specifies user-defined information about the file.
Required
When it is selected, indicates that the file is a required component file of the model that must be imported before using the model.
Report
When it is selected, indicates that the file is to be included in a SAS package file when a model is published to a channel.
Type
Specifies a file whose type is text or binary.
Fileref
Specifies an eight-character (or fewer) SAS file reference to refer to this file in score.sas code. The fileref is assigned by SAS Decision Manager when a SAS job is submitted.
Note: All user-defined models must have three files.
  • score.sas is the model's score code.
  • modelinput.sas7bdat is a SAS data set whose variables are used by the model score code. The contents of the data set is not used by SAS Decision Manager.
  • modeloutput is a resulting data set when a user runs score.sas against modelinput.sas7bdat. The data set provides output variables that the model creates after a scoring test is executed. The contents of the data set is not used by SAS Decision Manager.

System and User Properties

Here is a list of the system-defined and user-defined properties for a model template. Users can set these properties when they import a model.
Property Name
Description
Name
Identifies the name of the property. This is a required field.
Description
Specifies user-defined information about the property.
Type
Specifies a property whose type is String or Date.
Edit
Indicates that the property can be modified when importing a model or after the model is imported.
Required
Indicates that the property is required.
Initial value
Specifies a text string for the initial value for the property.
Display name
Specifies a text value that is displayed as the name of the property.

Specific Properties

Here is a list of specific properties for a model that identify the fundamental model data structures and some of the critical model life cycle dates. Where applicable, project-based or version-based data structures automatically populate properties for model-based data structures.
Property Name
Description
Default scoring input table
Specifies a default SAS data set that is used as the input data table for all of scoring tests within the project. The model's Default scoring input table property inherits the property value from the associated version or project, if one is specified.
Default scoring output table
Specifies a default SAS data set that defines the variables to keep in the scoring results table and the scoring test output table. The model's Default scoring output table property inherits the property value from the associated version or project, if one is specified.
Default performance table
Specifies the default performance table for all model performance monitoring tasks within a project.
A model's Default performance table property inherits the property value from the associated version or project, if one is specified. If you do not specify a performance table, some of the monitoring reports might not be enabled.
Default train table
The train table is optional and is used only as information. However, when a value is specified for a model's Default train table property.
Expiration date
Specifies a date property by which the selected model is obsolete or needs to be updated or replaced. This property is for informational purposes and is not associated with any computational action. This property is optional.
Model label
Specifies a text string that is used as a label for the selected model in model assessment charts. If no value is provided for the Model Label property, the text string that is specified for the Model Name property is used. The Model Label property can be useful if the Model Name property that is specified is too long for use in plots. This property is optional.
Subject
Specifies a text string that is used to provide an additional description for a model, such as a promotional or campaign code. This property is for informational purposes and is not associated with any computational action. This property is optional.
Algorithm
Specifies the computational algorithm that is used for the selected model. This property cannot be modified.
Function
Specifies the function class that was chosen when the associated project was created. The Function property specifies the type of output that models in the predictive model project generate.
Modeler
Specifies the Modeler ID or, when Modeler ID is missing, specifies the user ID of the individual who created the model that is stored in the SPK file for SAS Enterprise Miner models. Otherwise, the modeler can be specified during model import for local files.
Tool
Specifies whether the imported model came from SAS Enterprise Miner or from other modeling tools.
Tool version
Specifies the version number of the tool that is specified in the Tool property.
Score code type
Specifies whether the imported model score code is a DATA step fragment, ready-to-run SAS code, or a PMML file. Valid values are DATA step, SAS Program, and PMML.
Note: If the model is created using PMML 4.0, the Score Code Type is DATA step and not PMML.
Note: SAS Decision Manager cannot publish models to a database whose Score Code Type model property is set to SAS Program and PMML.
Template
Specifies the model template that was used to import the model and to create pointers to its component files and metadata.
Copied from
Specifies where the original model is if this model is copied from another model repository.
Target variable
Specifies the name of the target variable for a classification or prediction model. This property can be ignored for segmentation, cluster, and other models that do not use target variables. For example, if a model predicts when GENDER=M, then the target variable is GENDER.
Target event value
Specifies a value for the target event that the model attempts to predict. This property is used only when a value is specified for the Target Variable property. For example, if a model predicts when GENDER=M, then the target event value is M.