Adding Folders, Projects, Versions, and Properties Using Macros

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

SAS Model Manager provides four macros that you can use in a SAS program to add folders, project, 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.
%mdlmgr_SetProperty( )
Sets project and version properties that appear in the Specific Properties section of the project or version Properties tab in SAS Model Manager.
After you have added the project objects or set properties, you refresh the folder or project object o 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 the SAS Model Manager.

Writing Your SAS Program

Include these language elements in your SAS program:
Global macro variable to set the environment
%let _MM_Service_Registry_URL=
   %str(http://your-server.com:7980/SASWIPClientAccess/remote/ServiceRegistry); 
Global macro variable to define the user and a DATA step to provide the password
%let _MM_User = user_ID;
data _null_;
   infile pwfile obs=1 length=l; 
   input @;
   input @1 line $varying1024. l; 
   call symput('_MM_Password',substr(line,1,l)); 
run;
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=, Name=, 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.

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 lower case. 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.
When your DATA step specifies a library in the SAS Libraries tab, the text :sas-library must be appended to libref.table in lower case (for example, MySASLib.Property:sas-library and Work.ProjProp:sas-library). Libraries that are defined in the SAS Metadata Repository do not require the appended text.

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.
ProjectInputDS
None, it is used to create inputvar.xml.
The project input table in the form libref.table.
Set for a project.
ProjectOutputDS
None, it is used to create outputvar.xml.
The project output table in the form libref.table.
Set for a project.
ResponseDS
Default Performance Table
The default performance table in the form libref.table.
Set for projects and versions.
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
ResponseDS PERFDS.2013Q1:sas-library
ClassTargetEvent 1
ClassTargetLevel BINARY
EventProbabilityRole SCORE
ClassTargetVar BAD
;
run;
Note the difference in values for the ResponseDS property and the other table properties. In the Data Sources category view, the library MMLIB is defined in the SAS Metadata Repository tab and the library PERFDS is defined in the SAS Libraries tab. Because PERFDS is defined in the SAS Libraries tab, the value requires :sas-library to be appended to the libref.table value. Libraries that are defined in the SAS Metadata Repository do not require the appended text.