Cross-Variable Validation Rules

To use a cross-variable validation rule with the VALIDATEDATA procedure requires:

  1. A rule definition (using the DATAFILE ATTRIBUTE command).

    Creating a Rule Definition

    Cross-variable validation rules are attributes of the data file and are generally defined according to the following syntax diagram:

    DATAFILE ATTRIBUTE
     ATTRIBUTE=$VD.CRule[1]("Label='value',"+
                            "Expression='value'."+
                            "OutcomeVar='outcomevar'").

    Cross-variable rule attribute names must be of the form $VD.CRule[n], where n is a positive integer.

    • Each rule specification includes a list of properties that define the rule. Each property is required. The order in which properties appear does not matter. Unrecognized rule properties are ignored. If the same property appears more than once in a rule specification, the value for the last one is honored.

    Label. The label is text that uniquely identifies the rule among single-variable and cross-variable rules. It cannot be the null string. Leading and trailing blanks are trimmed for the purpose of determining the uniqueness of the label.

    Expression. The expression must be valid command syntax for the right side of a COMPUTE statement. Any variables used in the expression must exist in the data file.

    OutcomeVar. A rule outcome variable associated with the cross-variable rule.

  2. A rule outcome variable (using COMPUTE and VARIABLE ATTRIBUTE).

Creating a Rule Outcome Variable

COMPUTE outcomevar = expression.

VARIABLE ATTRIBUTE
  VARIABLES=outcomevar
  ATTRIBUTE=$VD.RuleOutcomeVar("Yes").
  • The COMPUTE expression for each outcome variable should generate the value 1 for invalid cases. It should be equivalent to the Expression in the cross-variable rule definition.
  • The rule outcome variable is marked as such using the VARIABLE ATTRIBUTE command. Rule outcome variable attribute names must be $VD.RuleOutcomeVar with the property Yes.