%BRM_RULE_FLOW

Runs rule flows. You can use the %BRM_RULE_FLOW macro to run packages that were created with the %BRM_GET_RULE_FLOW_CODE macro.

Requirement: This macro must be run on the server tier.

Syntax

FILENAME fileref "pathname";
%BRM_RULE_FLOW (INPUTTABLE=libref.table_name, MAPPING=mapfile.mapping,
FILELOCATION=fileref, RULEFIRE=Y | N<, THREADCOUNT=number> );

Required Arguments

INPUTTABLE=libref.table_name

specifies the libref and table name for the input table against which you want to run the rule flow.

MAPPING=mapfile.mapping

specifies the file that contains the variable mappings. This file is typically a SAS file. See Creating a Mapping Table.

FILELOCATION=fileref

specifies the fileref for the file that contains the DS2 package code for the rule flow. See SAS Statements: Reference for information about the FILENAME statement and how to define filerefs.

RULEFIRE=Y | N | S | D | Q

specifies whether rule-fired data is recorded when the rule flow is run.

Y records both summary and detailed rule-fired data.
N does not record any rule-fired data.
S records only summary rule-fired data.
D records only detailed rule-fired data.
Q collects rule-fired data but does not generate summary or detailed rule-fired tables. The rule-fired data is added to the output table in columns named Rule Fired Count and _RULEFIREDCOUNTS_1.

Optional Arguments

CODETYPE=DS1|DS2

determines whether SAS Business Rules Manager generates DS2 code or DATA step (DS1) code for rule flows. In many cases, you will get better performance by specifying DS1. However, consider specifying DS2 if your input data is in Teradata, Greenplum, or Hadoop, and you have installed the SAS Code Accelerator.

Default DS2

THREADCOUNT=number

specifies the number of processors that are available for concurrent processing. If the rule flow contains rules in either the INIT or FINAL sections, the value of the THREADCOUNT option is set to 1 when rule flow tests are run. This option is ignored when rule flows are executed in the database.

Default the value of the CPUCOUNT= system option
See CPUCOUNT= System Option in SAS System Options: Reference

Details

Running Rule Flows Dynamically

You can use the &DCM_USE_LATEST_VERSION and either the &DCM_RULEFLOW_NAME or &DCM_DEPLOYED_RULEFLOW_NAME macro variable to ensure that when a rule flow is run, the latest version of the rule flow is always used. If you specify both &DCM_RULEFLOW_NAME and &DCM_DEPLOYED_RULEFLOW_NAME, then the name specified by &DCM_DEPLOYED_RULEFLOW_NAME is used.
For &DCM_DEPLOYED_RULEFLOW_NAME, specify the name of the published rule flow and the identification number of the rule flow. You can find the published name and identification number in the Name column of the rule flow History page. For example:
%let DCM_DEPLOYED_RULEFLOW_NAME=published_flow_name(ID_number);
Note: If you specify &DCM_RULEFLOW_NAME and SAS Business Rules Manager finds multiple rule flows that match the specified name, it writes an error message in the SAS log, and the rule flow is not executed. If you encounter this issue, specify the specific rule flow by using &DCM_DEPLOYED_RULEFLOW_NAME.
Define these macro variables in preprocessing code such as the Preprocessing Code section of a rule flow test or in the Precode section of the Precode and Postcode tab in SAS Data Integration Studio. Define these variables before calling the %BRM_RULE_FLOW macro. For example:
%let DCM_USE_LATEST_VERSION=Y;
%let DCM_RULEFLOW_NAME=rule_flow_name;
Note: SAS Data Integration Studio uses the latest version of the rule flow that matches the variable mappings in the Business Rules transformation. SAS Business Rules Manager writes a note in the SAS log that states which version was selected.

Creating a Mapping Table

Note: You must create a mapping table only if you are invoking the %BRM_RULE_FLOW macro in SAS code. In SAS Data Integration Studio and in the SAS Business Rules Manager test interface, the mapping table is created for you.
You must supply a file that maps terms in the rule flow to columns in the input table. You can create this file manually, or you can create and run a rule flow test in SAS Business Rules Manager. The mapping tables that are created when a rule flow test is run are written to the WORK library. The code that produces the mapping table is written to the SAS log.
The mapping table also defines the names and structure of the output table, the rule-fired summary table, the rule-fired details table, and the test information table that are generated by the rule flow. The structure of the rule-fired summary table, rule-fired details table, and test information table is static, and you must define them as shown in Example: Creating a Mapping File for a Simple Rule Flow..
The number in the data set ID column in the example specifies which table the column that is being defined belongs to. The following table lists the possible values for this column and the default table names that are generated when a rule flow is run in SAS Data Integration Studio.
Data Set ID
Table
Contents
Name Generated by SAS Data Integration Studio
1
Rule-fired details
One row for each time that a rule evaluates to true. There might be multiple entries for the same rule, but each entry has different values for the _recordCorrelationKey and RULE_ACTION_FIRE_ID columns.
DCM_RULE_ACTION_FIRE
2
Test information
A single record that holds aggregate information about the execution of the rule flow.
DCM_DEPLOYMENT_EXECUTION
4
Input
Input data
5
Output
Output data
6
Rule-fired summary
A summary of how many times each rule fired.
DCM_RULE_FIRE_SUMMARY
Note: See Rule-Fired and Test Information Tables in SAS Business Rules Manager: User’s Guide for information about the columns in these tables.

Example: Creating a Mapping File for a Simple Rule Flow

The following example creates a mapping table that maps terms in the rule flow to an input table with five columns. The column names are EngineSize, Make, Model, MSRP, and Type.
The example assumes that the following librefs have been defined: RULEFIRE, DEPLOY, INDATA, and OUTLIB. It uses the table names listed the following table.
Data Set ID
Table
Libref and Table Name
1
Rule-fired details
RULEFIRE.Details
2
Test information
DEPLOY.ThisRun
4
Input
INDATA.InData
5
Output
OUTLIB.MyResults
6
Rule-fired summary
RULEFIRE.Summary
data work.MAPPING;
     attrib table length = $100;
     attrib column length = $100;
     attrib termid length = $100;
     attrib type length = $100;
     attrib datasetid length = $100;  
     attrib col_type length = $1;     
     attrib col_length length = $5;   
     attrib col_format length=$32;   
     attrib col_informat length=$32;
     call missing(of _all_);
stop;
run;
proc sql;
  insert into work.MAPPING 
  values ('RULEFIRE.Details','RULE_ACTION_FIRE_ID','RULE_ACTION_FIRE_ID','output','1','C','100','','')
  values ('RULEFIRE.Details','RULE_SET_SK','RULE_SET_SK','output','1','N','8','','')
  values ('RULEFIRE.Details','RULE_SET_NM','RULE_SET_NM','output','1','C','100','','')
  values ('RULEFIRE.Details','RULE_SK','RULE_SK','output','1','N','8','','')
  values ('RULEFIRE.Details','RULE_NM','RULE_NM','output','1','C','100','','')
  values ('RULEFIRE.Details','DEPLMT_SK','DEPLMT_SK','output','1','N','8','','')
  values ('RULEFIRE.Details','RULE_FLOW_SK','RULE_FLOW_SK','output','1','N','8','','')
  values ('RULEFIRE.Details','RULE_FLOW_NM','RULE_FLOW_NM','output','1','C','100','','')
  values ('RULEFIRE.Details','RULE_FIRE_DTTM','RULE_FIRE_DTTM','output','1','N','8','nldatm.',
          'nldatm.')
  values ('RULEFIRE.Details','DEPLMT_EXECUTION_ID','DEPLMT_EXECUTION_ID','output','1','C','100','','')
  values ('RULEFIRE.Details','ENTITY_PRIMARY_KEY','ENTITY_PRIMARY_KEY','output','1','C','1024','','')
  values ('RULEFIRE.Details','TRANSACTION_DTTM','TRANSACTION_DTTM','output','1','N','8','nldatm.',
          'nldatm.')
  values ('RULEFIRE.Details','_RECORDSEQUENCEKEY','_RECORDSEQUENCEKEY','output','1','N','8','','')
  values ('DEPLOY.ThisRun','DEPLMT_SK','DEPLMT_SK','output','2','N','8','','')
  values ('DEPLOY.ThisRun','DEPLMT_NM','DEPLMT_NM','output','2','C','100','','')
  values ('DEPLOY.ThisRun','TRANSACTION_MODE_CD','TRANSACTION_MODE_CD','output','2','C','20','','')
  values ('DEPLOY.ThisRun','RECORDS_PROCESSED_NO','RECORDS_PROCESSED_NO','output','2','N','8','','')
  values ('DEPLOY.ThisRun','TEST_FLG','TEST_FLG','output','2','C','1','','')
  values ('DEPLOY.ThisRun','START_DTTM','START_DTTM','output','2','N','8','nldatm.',' nldatm.')
  values ('DEPLOY.ThisRun','END_DTTM','END_DTTM','output','2','N','8','nldatm.','nldatm.')
  values ('RULEFIRE.Summary','RULE_SK','RULE_SK','output','6','N','8','','')
  values ('RULEFIRE.Summary','RULE_NM','RULE_NM','output','6','C','100','','')
  values ('RULEFIRE.Summary','RULE_SET_SK','RULE_SET_SK','output','6','N','8','','')
  values ('RULEFIRE.Summary','RULE_SET_NM','RULE_SET_NM','output','6','C','100','','')
  values ('RULEFIRE.Summary','RULE_FLOW_SK','RULE_FLOW_SK','output','6','N','8','','')
  values ('RULEFIRE.Summary','RULE_FLOW_NM','RULE_FLOW_NM','output','6','C','100','','')
  values ('RULEFIRE.Summary','ruleFiredCount','ruleFiredCount','output','6','N','8','','')
  values ('INDATA.InData','EngineSize','EngineSize','input','4','N','8','','')
  values ('INDATA.InData','Make','Make','input','4','C','13','','')
  values ('INDATA.InData','Model','Model','input','4','C','40','','')
  values ('INDATA.InData','MSRP','MSRP','input','4','N','8','','')
  values ('INDATA.InData','Type','Type','input','4','C','8','','')
  values ('OUTLIB.MyResults','EngineSize','EngineSize','output','5','N','8','','')
  values ('OUTLIB.MyResults','Make','Make','output','5','C','13','','')
  values ('OUTLIB.MyResults','Model','Model','output','5','C','40','','')
  values ('OUTLIB.MyResults','MSRP','MSRP','output','5','N','8','','')
  values ('OUTLIB.MyResults','Type','Type','output','5','C','8','','')
  ;
quit;
Last updated: February 22, 2017