Data editing > Data validation > Column and code validation > Checking codes in columns
 
Checking codes in columns
Quick reference
To check for specific codes in a column, type:
r [/err_code/] condition col1'codes1' [, col2'codes2' ... ]
codes1
The codes to be tested for in column or field col1
codes2
The codes to be tested for in column or field col2.
Any codes which are present in col1 but are not listed in codes1 are ignored. The same applies to any other column and code pairs listed.
More information
Sometimes it is not sufficient to check just the type of coding, and you will want to know whether the codes found are valid for that column. To do this, use the information given in the previous section as a base, and add on the first ‘optional extra’.
To check whether a column or field of columns contains specific codes, follow the column specification with the codes to be checked, enclosed in single quotes. For example:
r /5/ sp c223'1/5'
tells you that column 223 should be single-coded within the range of codes 1 through 5. Any other codes in this column are ignored. Thus, a record in which c223’14’ is incorrect because it contains two of the listed codes, whereas a record in which c223’27’ is correct because it contains only a 2 from the range ‘1/5’. Of course, any record which does not contain a 1, 2, 3, 4 or 5 at all is also incorrect, regardless of whether or not it is single-coded: c223’9’ is just as wrong as c223’789&’.
Codes can also be defined with all other code types, thus:
r /3/ nb c156'2/6'
If c156 does not contain at least one of the codes 2 through 6 (regardless of anything else it might contain) the record is printed out. Column 156 can be multicoded as long as at least one of the codes is within the required range.
----+----6 ----+----6 -----+----6
1 2 2
2 and 7 and 5
8 8
are valid, but:
----+----6
9
is not because ‘9’ is not one of the listed codes.
Even though it checks for blanks, require b can be followed by columns and codes. Do this when you are checking that a column is either blank or, if not blank, that it does not contain certain codes. Here’s an example to clarify this:
r b c134'1/8'
This statement tells Quantum that column 134 must never contain any of the codes 1 through 8: only ‘09-&’ or blank are acceptable. This is the opposite of r sp and r nb, both of which list valid codes. Any record failing this condition will be printed and rejected via the default action code 3.
See also
Column and code validation