SETCALCULATE directive

Performs Boolean set calculations on the contents of vectors or pointers.


Options

NULL = scalar
Returns either 1 or 0 according to whether or not the result is a null (i.e. empty) set

FREPRESENTATION = string
How to represent factors in a calculation that contains only factors (levels, labels); default leve

TOLERANCE = scalar
Tolerance to use when comparing numerical values; default 10-6


Parameter

    expression
Expression defining the calculation to be performed


Description

The SETCALCULATE directive allows you to perform set operations. The calculation must have a single assignment, setting a pointer, variate, text or factor to the result of a set calculation involving other compatible structures. Calculations on pointers must involve only pointers, those on variates and those on texts can involve factors, while those on factors can involve either variates or texts but not both.

   For example, you can form a variate All that contains all the distinct values that occur in either of a pair of variates x and y using the .OR. operator

SETCALCULATE all = x .OR. y

or all the (distinct) values that occur in both of them using the .AND. operator

SETCALCULATE both = x .AND. y

   The available operators are as follows:

    .OR.
represents the Boolean "or" operation: for example x.OR.y produces a vector that contains any item that is in either x or y

    .AND.
represents the Boolean "and" operation: for example x.AND.y produces a vector that contains any item that is in both x and y

    .EOR.
represents "either or": for example x.EOR.y produces a vector that contains any item that is in either x or y but not both of them

    -
represent "not", for example x-y produces a vectors that contains the items that are in x but not in y

    +
synonym of .OR.

    ,
synonym of .OR.

    *
synonym of .AND.

   The NULL option can save a scalar whose value is 1 if the calculation generates an null set (i.e. one that has no members); otherwise the scalar is set to 0. The FREPRESENTATION option determines whether the values of factors are compared using their levels or their labels; by default the levels are used. The final option, TOLERANCE, defines the tolerance to be used when comparing numbers. The default value 10-6 should be suitable, however, unless the variates contain very small values.

 

Options: NULL, FREPRESENTATION, TOLERANCE.

Parameter: unnamed.


Action with RESTRICT

SETCALCULATE ignores any restrictions on vectors in the expression.