Data editing > Data validation > Column and code validation > Checking type of coding
 
Checking type of coding
Checking with require can be as simple or complex as you like. This section starts with the simplest checks and deal with each extra feature in turn. Assume, unless otherwise stated, that the error action code is the default Print and Reject (code 3) and; it is omitted from most of the examples accordingly.
The most basic form of the require statement checks whether the column or field of columns contains the correct type of code; it does not check the individual codes themselves. Code types can be:
Code
Description
b
Blank
nb
Not blank (single-coded or multicoded)
sp
Single-coded (literally, single-punched)
spb
Single-coded or blank
One of these types must follow the word require since it tells Quantum what to check for.
All that remains is to say which columns are to be inspected; just list each column or field of columns at the end of the statement. If more than one column or field is defined, each one must be separated by a comma.
Here are some examples in which the record to be checked is:
----+----1----+----2----+----3----+----4----+
002411123481231&- *1927235537*&& 1 1 1
The statement:
r nb c10, c(25,35)
checks that columns 10, and 25 to 35 inclusive are not blank — they can contain any number of codes. This record satisfies both conditions so it passes on to the next statement in the edit.
The statement:
r sp c11, c15, c23, c41
looks to see whether columns 11, 15, 23 and 41 are single-coded. In the record they are, but if this were not the case (say c11’123’) the record would be printed out and rejected from any tables that might be produced. Additionally, Quantum says, ‘Column 11 is 123’.
Note Be careful when using field specifications with require: the condition applies to each column individually, not to the field as a whole. For example:
r sp c(1,4)
means that each of columns 1, 2, 3 and 4 must contain one code. It does not mean that the field must contain one code overall. To check that a field contains one code only, use numb. For more information about numb, see Expressions.
Very often some columns on the questionnaire are not used, so you might like to check that all such columns are blank in the data file. In the example, say that columns 51 to 70 are not used. To check that there are no stray codes in these columns, write:
r b c(51,70)
See also
Column and code validation