Data editing > Data validation > Testing the equivalence of logical expressions
 
Testing the equivalence of logical expressions
Quick reference
To test whether a group of logical expressions all have the same logical value, type:
r = [/err_code/] (expression1) (expression2) ...(expressionn)[$message$]
There must be a space between r and the = sign.
Require can evaluate groups of expressions and perform given tasks depending on whether all expressions are true or all are false. When all the expressions have the same value (that is, all true or all false) Quantum continues with the next statement in the program, whereas if some are true and some are false, the record being tested will be dealt with according to the given (or default) error action code.
This statement has five parts:
1 The word require or the letter r.
2 An equals sign which must be preceded by a space.
3 An optional action code.
4 The expressions to be evaluated, each one enclosed in parentheses.
5 Optional error text enclosed in dollar signs.
This type of statement is generally used to check routing patterns. For example: if a ‘2’ in c125 means that the respondent did not try Brand A washing powder, you might expect columns 126 to 145 which record their opinion of it to be blank. On the other hand, if they tried the washing powder, you would expect to find their opinions about it coded in columns 126 to 145. This can be written:
r = (c125'2') (c(126,145)=$ $)
which says that to be accepted, a record must either have a ‘2’ in column 125 and blanks in columns 126 to 145, or something other than a ‘2’ in c125 with at least one code somewhere in c(126,145). The following data is designed to clarify this.
----+----3----+----4----+----5
2 15
is accepted, so is
----+----3----+----4----+----5
15 42674 262&03 37 73
9 4 0
but
----+----3----+----4----+----5
2 6 8 15
is rejected, so is
----+----3----+----4----+----5
3 635
The first example is accepted because both expressions are true, the second is accepted because both expressions are false. The third and fourth expression are both rejected because one expression is true and the other is false.
In this example, if column 125 does not contain a ‘2’, it checks only that columns 126 to 145 contain at least one code; it does not check whether those codes are correct.
See also
Data validation