Comparing variables and arithmetic expressions to a list
Quick reference
To compare the value of a variable or an arithmetic expression to a list of numbers, type:
item .in. (value1,value2, ... )
in the edit section. Ranges of numbers may be entered in the list as start:end. If the item is a reference to a field containing blanks, enter the values as strings of codes enclosed in dollar signs.
More information
You might need to check whether a variable or arithmetic expression has one of a given list of values. For example, if the questionnaire codes brands of frozen vegetables as 3-digit codes into columns 145 to 147, you might want to check that only valid codes appear in this field. To do this, use the logical expression .in. like this:
variable-name .in. (list)
or
arithmetic-exp .in. (list)
where variable-name is that of the variable to be checked, and list is a list of permissible values. The arithmetic expression is an expression consisting of data or integer variables, arithmetic operators and integer values. If the variable or arithmetic expression has one of the listed values, the expression is true, if not, it is false.
The left side of the expression may contain integer variables, columns or data variables containing whole numbers, or expressions using these types of variables. If it is a data variable, then the list may contain codes enclosed in dollar signs. Quantum then compares the codes in the data variable with the codes inside the dollar signs. Therefore, you can check that the frozen vegetables have been coded correctly by using a statement like this:
c(145,147) .in. ($205$,$206$,$207$,$210$,$215$,$220$)
Quantum flags any records in which c(145,147) does not contain exactly 205, 206, 207, 210, 215 or 220 (that is, three single-coded columns) as incorrect.
If the data variable contains a valid positive or negative whole number, then the list may also contain such values. Ranges of values may be entered in the form min:max, where min is the lowest acceptable value and max is the highest. Since the frozen vegetables have numeric codes, you could write the expression as:
c(145,147) .in. (205:207,210,215,220)
Any columns in the field which contain non-numeric data (for example, multicodes) are be flagged as incorrect, as are any which contain values which do not match the specification.
Sometimes, though, the codes and numbers are not interchangeable. If you have 2-digit codes in a 3-column field, the statement:
c(206,208) .in. ($ 10$,$ 11$,$ 12$,$ 13$)
is not the same as:
c(206,208) .in. (10:13)
unless column 206 is always blank. If the 2-digit codes have been padded on the left with zeros instead of blanks (that is, 010, 011) or if they all start in column 206 (that is, $10 $, $11 $), then the first expression will be false, even though the second one is still true.
If the left side of the expression is an integer variable or an arithmetic expression, the list may contain positive or negative whole numbers:
total .in. (100,200,500:1000)
Lists may contain up to 247 values or codes, which may be entered in any order; the exception is numeric ranges which must be entered in the form lowest:highest.
See
See also