This content describes Snap 11. For Snap 10, the equivalent page will be in Snap 10 help

Next Topic

Book Contents

Book Index

Relational Operators

Relational Operators are used to compare single or multiple values. These can be represented by variable names, numeric expressions or numeric lists.

To determine whether the variable called REGION has code 4 set, specify REGION=4

It is frequently necessary to determine whether a variable has one of a number of values. For example, to test whether the value in REGION was any of 2, 3 or 4, specify REGION=(2,3,4) (note the use of parentheses). Following the guidelines outlined for numeric lists, it is shorter to specify REGION=(2~4) or REGION=(2 to 4)

Table of relational operators

Operator

Description

=

MT

Matches. If only single or quantity response operands are compared the result is TRUE if the first operand is numerically equivalent to the second. If either operand is multiple then the result is TRUE if any of the codes set in the first operand are also set in the second. If both operands are literal response then the result is true if the second operand is a substring of the first. If both operands are dates or times the result is true if both are the same date or time.

==

EQ

Equals. The result is TRUE if the first operand is identical to the second. For single, quantity, date and time response operands, the EQUALS operator gives the same result as the MATCHES operator, above. However, if either operand is multiple then the result is TRUE only if exactly the same codes are set in both operands. If they are literal response then the result is TRUE when both strings are identical.

<>

NE

Is Not Equal. The result is TRUE if the first operand is not identical to the second. This operator returns the opposite of the EQUALS operator above and not opposite to the MATCHES operator.

<

LT

Is Less Than. The result is TRUE if :

- both operands are single or quantity and the first operand is numerically less than the second
- both operands are dates and the first date is before the second
- both operands are times and the first time is before the second
- both operands are literal and the first operand is alphabetically before the second

If either operand is a multiple response value or either is an error then the result is an Error.

<=

LE

Is Less Than Or Equal To. The result is TRUE if

- both operands are single or quantity and the first operand is numerically less than or equal to the second
- both operands are dates and the first date is before, or the same as, the second
- both operands are times and the first time is before, or the same as, the second
- both operands are literal and the first operand is alphabetically before, or the same as, the second

If either operand is a multiple response value or either is an error then the result is an Error.

>

GT

Is Greater Than. The result is TRUE if:

- both operands are single or quantity and the first operand is numerically greater than the second
- both operands are dates and the first date is after the second
- both operands are times and the first time is after the second
- both operands are literal and the first operand is alphabetically after the second

If either operand is a multiple response value or either is an error then the result is an Error.

>=

GE

Is Greater Than Or Equal To. The result is TRUE if:

- both operands are single or quantity and the first operand is numerically greater than, or equal to, the second
- both operands are dates and the first date is the same as or after the second
- both operands are times and the first time is the same as or after the second
- both operands are literal and the first operand is alphabetically after, or the same as, the second

If either operand is a multiple response value or either is an error then the result is an Error.

@

Is a sub-string of. The result is TRUE if:

- both operands are strings and the first operand contains the second

See Also

Logical Functions

Logical Operators