Adding Folders, Projects, Versions, and Properties Using Macros

Overview of Using a SAS Program to Add Folders, Projects, Versions, and Properties

Note: You must make sure that you can access the SAS Model Manager web application before using these macros. If you cannot access the web application, contact your SAS application administrator for assistance. For instructions on how to access the web application, see Sign In in SAS Model Manager: User’s Guide.
SAS Model Manager provides four macros that you can use in a SAS program to add folders, projects, and versions, and to set properties:
%mdlmgr_AddFolder( )
Adds a folder under MMRoot or adds a subfolder.
%mdlmgr_AddProject( )
Adds a project under a folder or a subfolder.
%mdlmgr_AddVersion( )
Adds a version to a project.
Note: When you use the %mdlmgr_AddProject( ) to create a new project, an initial version is automatically created within the new project. The default version is 1.0. In order to add a new version to an existing project, use the %mdlmgr_AddVersion( ) macro.
%mdlmgr_SetProperty( )
Sets project properties that appear in the Specific section of the project Properties tab in SAS Model Manager.
After you have added the project objects or set properties, you refresh the folder or project object to see the new objects and property settings in the SAS Model Manager. You can then use these objects in SAS Model Manager to further define your projects and versions.
To delete a folder, project, or version, you use SAS Model Manager.

Writing Your SAS Program

Include these language elements in your SAS program:
If you are setting properties, use a DATA step to create a table that contains property and value pairs.
One of the %mdlmgr_SetProperty( ) arguments is the name of a table that contains property-value pairs. Creating the Properties Table lists the properties that you can include in the table. When you create the table, the first column must be Name and the second column must be Value. Both columns must be character. See Example: Creating a Properties Table.
Access the macros by using the FILENAME and %INCLUDE statements.
filename file1 catalog 'sashelp.modelmgr.accessmacros.source';                                                                                                                                                                                             
%include file1;                                                                                                                                                                                                                                            
filename file1;

filename file2 catalog 'sashelp.modelmgr.mdlmgr_addfolder.source';                                                                                                                                                                                             
%include file2;                                                                                                                                                                                                                                                
filename file2;

filename file3 catalog 'sashelp.modelmgr.mdlmgr_addproject.source';                                                                                                                                                                                             
%include file3;                                                                                                                                                                                                                                                
filename file3;

filename file4 catalog 'sashelp.modelmgr.logtrace.source';                                                                                                                                                                                             
%include file4;                                                                                                                                                                                                                                                
filename file4;

filename file5 catalog 'sashelp.modelmgr.mdlmgr_addversion.source';                                                                                                                                                                                             
%include file5;                                                                                                                                                                                                                                                
filename file5;

filename file6 catalog 'sashelp.modelmgr.mdlmgr_setproperty.source';                                                                                                                                                                                             
%include file6;                                                                                                                                                                                                                                                
filename file6;
You can change the fileref name.
Call the macros:
%mdlmgr_AddFolder(ParentId=, Name=, Desc=, NewFolderId=, Trace=);

%mdlmgr_AddProject(ParentId=, Name=, Desc=, ModelFunction=,
                   InputVarTable=, OutputVarTable=, NewProjectId=, Trace=);

%mdlmgr_AddVersion(ParentId=, Desc=, NewVersionId=, Trace=);

%mdlmgr_SetProperty(FolderId=, Table=, PropertyType=, FolderType=, Trace=);
There is no requirement to call all of the macros in the same SAS program.
When SAS returns from a macro call that adds a node, the value of NewFolderId=, NewProjectId=, and NewVersionId= is used to create a global macro variable that can be referenced by other macros in the same SAS session. The value of the macro variable is the UUID or the model repository path for the node that is added. You can then use that macro reference as a value for the ParentId= argument of another macro or for the %mdlmgr_SetProperty( ) macro FolderId= argument. For example, in the %mdlmgr_AddProject( ) macro, if you set NewProject=projectId, the variable name projectId is used to create the global macro variable %projectId. The &projectId macro reference can now be used as the value of the ParentId= argument in the %mdlmgr_AddVersion( ) macro, ParentId=&projectId. The same macro reference can be used as a value for the FolderId= argument in the %mdlmgr_SetProperty( ) macro, FolderId=&projectId.
If you are running macros in a SAS session that requires a connection to the SAS Metadata Server, you must specify the metadata connection system options before you run the macros. If these options are not specified, you will be prompted for the information. If you are running the macros in batch mode, you must include the metadata connection system options. Otherwise, you will receive a failure message. For more information, see Setting Metadata Connection System Options.

Creating the Properties Table

Property Table Requirements

To set project properties, you use a DATA step to create a data set that contains property-value pairs. The data set variables must be Name and Value, and they must be character variables.
In the data set, property names can be mixed case. The required appended text, :sas-libraries, must be lowercase. For more information, see Specifying Data Sets.

Specifying Data Sets

Some property values specify the name of a default table, such as the default train table or the default performance table. You specify tables using the form SMRLibrary.table for libraries in the SAS Metadata Repository and libref.table for SAS libraries. See the Data Sources category view for valid library and table names. In the SAS Metadata Repository tab, SMRLibrary is the folder-name where the data set in stored. In the SAS Libraries tab, libref can be one of the librefs under the SAS Libraries node.

Properties That You Can Set

Use a property in the following Property Name column as a value for the Name variable in the property table.
Project and Version Properties That Can Be Set by %mdlmgr_SetProperty( ) Macro
Property Name
Property Name As It Appears in the SAS Model Manager
Valid Values
ClassificationRole
Output Event Probability Variable
A text string that specifies the output event probability variable.
Set for a project with a model function of classification.
ClassTargetEvent
Class Event Value
A number that represents the target event value.
Set for a project.
ClassTargetEventValues
Class Target Values
A text string that represents the class target values.
Set for a project.
ClassTargetLevel
Class Target Level
One of the following text strings:"BINARY", "NOMINAL", "ORDINAL", or "INTERVAL"
Set for a project.
ClassTargetVar
Training Target Variable
A text string that indicates the training target variable
Set for a project.
EventProbabilityRole
Output Event Probability Variable
A text string that specifies the output event probability variable.
Specify this property only if you specify the outputVarTable= argument in the %mdlmgr_AddProject( ) macro. The value of EventProbabilityRole must be a variable in the project output table.
Set for a project.
Function
Model Function
A text string that specifies the model function. Valid values are "CLASSIFICATION", "PREDICTION", "SEGMENTATION", and "ANALYTICAL".
Set for project,
InterestedParty
Interested Party
A text string that specifies a person or group that has an interest in the project.
Set for a project.
MetadataLock
Lock Project Metadata
Specify "YES" or "NO" to indicate whether the project metadata is locked.
Set for a project.
PredictionRole
Output Prediction Variable
A text string that specifies the output prediction variable.
Set for a project with a model function of prediction.
ScoreInputDS
Default Scoring Input Table
The default scoring test input table in the form libref.table.
Set for projects and versions.
ScoreOutputDS
Default Scoring Output Table
The default scoring test output tablet in the form libref.table.
Set for projects and versions.
SegmentRole
Output Segmentation Variable
A test string that specifies the output segmentation variable.
Set for a project with a model function type of segmentation.
State
State
Select one:
0 Under Development
1 Active
2 Inactive
3 Retired
Set for a project.
TestDS
Default Test Table
The default test table in the form libref.table.
Set for projects and versions.
TrainDS
Default Train Table
The default train table in the form libref.table.
Set for projects and versions.

Example: Creating a Properties Table

Here is a sample DATA step to create a properties table:
data HMEQProp;
   length name $20;
   length value $40;
   input name value;
   datalines;
TestDS MMLIB.HMEQ_TEST
ScoreInputDS MMLIB.HMEQ_SCORE_INPUT
ScoreOutputDS MMLIB.OUTPUT
TrainDS MMlib.HMEQ_TRAIN
ClassTargetEvent 1
ClassTargetLevel BINARY
EventProbabilityRole SCORE
ClassTargetVar BAD
;
run;
Last updated: February 14, 2017