Data editing > Data validation > Column and code validation > Exclusive codes
 
Exclusive codes
Quick reference
To check that a column or field contains no codes other than those listed, type:
r [/err_code/] condition col1'codes1'o
If col1 contains any codes other than those given in codes1, the test is false.
More information
This section describes how to check that all other code positions are blank.
Statements of the form:
r sp ca'p'
accept all records containing only one of the codes ‘p’ in column a, regardless of what other codes are also present. To check that a column contains only the listed codes and nothing else, follow the code specification with the letter o (for only) in upper or lower case. For example, to indicate that c356 must be single-coded in the range ‘1/5’ and that all other positions (‘6/&’) must be blank, you should type:
r sp c356'1/5'o
which is the same as:
if (c356'6/&'.or.numb(c356).ne.1) write; reject
Any of the following cause the record to be printed and rejected:
c356'34'
c356'59'
c356'8'
c356' '
The require statement can define conditions for more than one column. Just follow each column with the code positions to be checked and separate each set with a comma:
r sp c164'12-', c165'1/70', c166'1/3', c167'1/9-', c168'1/5'
Here the columns to be checked are consecutive but have been listed separately because they each have different sets of valid codes. If all columns could be single-coded in the range 1 to 7, you can abbreviate this to:
r sp c(164,168)'1/7' $q10a/e$
since this notation means that each column in the field must be single-coded within the given range rather than that the field as a whole can contain only one of those codes.
See also
Column and code validation