In this article
Question q4 of the car survey asks for the respondent's age. The answer options are - :
Figure 1 - The q4 answer options
If you wish to check whether a respondent selected “under 18” or “68 or older”, you would write the following:
if (q4 == "1" || q4 == "5") { }In the event a respondent belongs to this group, you could for example order a recoding of the variable such that this record is flagged for further investigation.
if (q4 == "1" || q4 == "5")
{
NeedsCheck = "2"; //Not ok
}
else
NeedsCheck = "1"; //ok
In this example, the variable NeedsCheck would indicate whether a record needs further validation, and could be used as a filter to filter out those records.