Defaults in a require statement
Quick reference
To define defaults for all columns or fields tested, type:
r type ['codes'][o] [:'new_code'] columns
The defaults can be overridden for an individual column by following the column with the required coding, only flag and replacement code as usual.
More information
require statements can become lengthy things, especially when specific codes have to be checked, replacement characters defined and error texts entered. In many cases some, if not all, of these items are common to the majority of the columns listed in the statement; for example, several non-consecutive columns can have the same set of valid codes.
When this happens, you can enter these common items at the beginning of the require statement as defaults for that statement. There are several ways of doing this; for example:
r spb c127'0/9'o, c129'0/9'o, c131'0/9'o, c133'0/9'o
This can be more efficiently written as:
r spb '0/9'o c127, c129, c131, c133
Both statements check whether columns 127, 129, 131 and 133 are single-coded n the range 0 to 9 or are blank. If the - or & codes appear in any of these columns, or if the columns are multicoded, the offending records will be printed and rejected.
Defaults defined at the start of a require can be overridden for an individual column or field by following that item with the new specification. For example:
r sp '1/5' c10, c12, c15, c20'1/3'
indicates that columns 10, 12 and 15 must be single-coded in the range 1 to 5 while column 20 must be single-coded in the range 1 to 3.
Here is another example which uses the Only operator:
r sp '1/5'o c10, c12, c15, c20'1/7', c24
This checks that columns 10, 12, 15 and 24 are single-coded in the range 1 to 5 and that none of the codes ‘6/&’ are present in those columns. Column 20 has its own code specification which overrides not only the default codes but also the Only operator. Quantum checks that c20 contains only one of the codes 1 to 7, but it will ignore anything it finds in the range ‘8/&’.
The following statement is the same as the previous example except that it has a replacement code to be used when errors are found. This code refers to all columns named with this require, even though column 20 has a different set of valid codes.
r sp '1/5'o :'&' c10, c12, c20'1/7', c24
See also