Data editing > Data validation > Actions when a require statement fails
 
Actions when a require statement fails
When Quantum executes a require statement, it sets the variable failed_ to True if the data fails the require statement or to False if the record passed the requirement. You can then test whether failed_ is True and take whatever actions you want. For example, if you are checking that the respondent’s sex is coded as a ‘1’ or a ‘2’ only, you might want to blank out the column if it contains any other code or codes. You could write this as:
r sp c123'12'
if (failed_) set c123' '
The test for failure is made on the last require statement executed for the current record. This might not always be the most recent require statement in the program, and it might not be the require statement you intend Quantum to execute. If you write:
r sp c112'1/5'
if (c115'1') r b c116
if (failed_) set c116' '
the test for failure could apply to either of the previous statements. If column 115 does not contain a ‘1’, the second require statement is not executed and failed_ is True if column 112 is not single-coded in the range ‘1/5’. If column 115 contains a ‘1’, then failed_ is True if column 116 is not blank.
You can get around this potential problem by setting failed_ to zero (the equivalent of False) just before the require statement you want to test. For example:
r sp c112'1/5'
failed_ = 0
if (c115'1') r b c116
if (failed_) set c116' '
See also
Data validation