You can check for errors at the time you enter the data or perform
interactive editing after the data have already been entered.
You can use the same programmed logic that was in effect during data entry to find problems that were left unresolved by the original keyer, or you can use different logic to check for other conditions.
Improperly identifying errors can waste precious personnel resources, so a precise set of rules should be developed with input from subject-matter specialists.
During data entry the system automatically displays a message if value for item is out-of-range. However, you might want to write your own message for missing or out-of-range values. For example, if enumerators had been instructed to record all persons older than 110 years of age as '110,' the first-pass check for errors might include the following code:
So what does this code do? If a person's age is in the range from 0 to 110 ('0' is for infants born less than 12 months before the Census reference date), then the value is accepted as valid and program flow exits the procedure. If not, then the value is either outside this range or missing, in which case the subsequent
errmsg statement will be executed, showing the reported age for Person N.
More involved edits may be needed for other variables. For example, fertility information is only asked of a female of a certain age. So if fertility information is present, you may wish to confirm the values of other variables. A possible test could be as follows:
PROC FERTILITY
if FERTILITY in 0:20 then // there are 0-20 children
if SEX = 1 then // if sex = male
errmsg("male has fertility info present"); // message displayed
reenter; // operator must enter valid value
else // sex is not male
if SEX = 2 then // if sex = female, check woman's age
if AGE < 15 then // 15 = minimum age for fertility
errmsg("woman is too young (%d) to have children", AGE);
endif;
endif;
endif;
else // fertility is blank
if SEX = 2 then // a problem if the woman is "of age"
if AGE >= 15 then
errmsg("woman aged %d should have fertility info", AGE);
endif;
endif;
endif;
As you see, the complexity of the logic used to find (and soon, correct!) errors will depend on the specifications provided. In the case where specifications are minimal, it is important that the programmer consider all situations/paths in developing the logic.