Hello!
Q1. completed age in years_______ (hint: age 0-99).
Q2. is the respondent eligible for interview? (hint: 10-19 are eligible)
1. Yes (if age between 10-19)
2. No (if 0-9 and 20-99 are not eligible)
Now i need to control and check by constraint for both conditions in "Q2" variable.
Could you please help me by somebody expert?
Any assistance is highly appreciated...
Dev Maharjan
Hi Dev,
I think you might want to use a relevant
instead of constraint
.

You can wrap your survey questions in a group that has a relevant
test for the desired age, or proceed to a different group if the age answer means the respondent is not eligible.
Let me know if this helps or if I didn't understand your question!
-Dan
1 Like
Dear Dan
It's great having your quick response. The problem is a part of household roster so i can not use relevant. Maybe i could not share in correctly in the previous post. I am trying to share in more details;
Q1. completed age in years_______ (hint: age 0-99).
Q2. is the respondent eligible for interview? (hint: 10-19 are eligible else are ineligible i.e. 0-9 and 20-99)
Choices
- Yes
- No
Suppose, in Q1= 15
Q2=1 (if interviewer input mistakenly 2 there must be constraint and constraint-msg as well)
and Second,
in Q1=25
Q2=1 (Suppose interviewer input 1 instead of 2, it is incorrect input so i want to make sure to avoid enter wrong here)
i hope it is more clearer than previous. Dear Dan, i am trying to use constraint instead of
relevant because it is for household roster. You know very well it is not easy to check in data-set. I hope now you can help in constraint syantax.
Thank you very much,
Dev Maharjan
Does the below work for your purposes? When the first input of the if
statement evaluates true
(that the answer to q1 is >9 and <20) then the constraint is the second input (q2 must be answered 'yes'). If evaluates to false
then the constraint is the third input (q2 must be answered 'no').
survey
+---------------+------+-------------------------------------------+--------------------------------------------------------------+-----------------------------------------+------------------------------------------------+
| type | name | label | hint | constraint | constraint_message |
+---------------+------+-------------------------------------------+--------------------------------------------------------------+-----------------------------------------+------------------------------------------------+
| integer | q1 | Completed age in years? | (age 0-99) | .>=0 and .<100 | |
+---------------+------+-------------------------------------------+--------------------------------------------------------------+-----------------------------------------+------------------------------------------------+
| select_one yn | q2 | Is the respondent eligible for interview? | (10-19 are eligible, else are ineligible i.e. 0-9 and 20-99) | if(${q1}>9 and ${q1}<20,.='yes',.='no') | provided age does not match eligibility answer |
+---------------+------+-------------------------------------------+--------------------------------------------------------------+-----------------------------------------+------------------------------------------------+
choices

1 Like
Dear Dan
Thank you very much....cheers
Dev