Hi people, I would like to solve a little problem I have in my application. How can I skip a field based on a checkbox or radio button selected? Ex: I have 4 option for the first question (V1): 1,2,3,4. If I select the checkbox for the number "1" I wanna to skip the next question and to focus on the third question (V3). I tried whit the code below, but it didn´t work. Please I need your help.
PROC V1
//IF V1 = 1 THEN
//SKIP TO V3
//ENDIF
Comparing checkbox values
Re: Comparing checkbox values
Checkboxes are strings (alpha variables) where the code for each option that is checked is included in the string. For example if you have a variable CROPS with the following value set:
Rice - "1"
Maize - "2"
Millet - "3"
Sorghum - "4"
and the interviewer checks Maize and Sorghum then the value of CROPS will be "24". If they check just Rice then the value will be "1". If they check Rice, Sorghum and Maize then it will be "124".
So to determine if they selected Rice you need to figure if "1" is included in the string CROPS. You can do this using the pos() function. pos() returns the starting position of a string in another string. For example pos("J", "Josh") returns 1, pos("s", "Josh") returns 3. If the search string is not found then pos() returns zero. For example pos("K", "Josh") returns zero. So to see if "1" is in CROPS you need to check if pos("1", CROPS) is anything other than zero:
if pos("1", CROPS) then
skip to V3;
endif;
Rice - "1"
Maize - "2"
Millet - "3"
Sorghum - "4"
and the interviewer checks Maize and Sorghum then the value of CROPS will be "24". If they check just Rice then the value will be "1". If they check Rice, Sorghum and Maize then it will be "124".
So to determine if they selected Rice you need to figure if "1" is included in the string CROPS. You can do this using the pos() function. pos() returns the starting position of a string in another string. For example pos("J", "Josh") returns 1, pos("s", "Josh") returns 3. If the search string is not found then pos() returns zero. For example pos("K", "Josh") returns zero. So to see if "1" is in CROPS you need to check if pos("1", CROPS) is anything other than zero:
if pos("1", CROPS) then
skip to V3;
endif;