Hello, I am trying to create a new variable by combining the response options from 9 other variables. The response options range from 1 to 16 on each of the 9 other variables. I would like all the response options currently coded as 1 to remain 1 and the other response options (2-16) on all of the 9 separate variables to all be coded as 0. Essentially, I am trying to code respondents who said they have ate broccoli during the last 30 days compared to the other 15 response options, so the resulting variable would be broccoli consumption vs. any other vegetable. While the original question on the questionnaire is one question asking respondents to identify which types of vegetables they have consumed (so respondents could enter multiple responses if they ate more than one vegetable type), the dataset contains 9 separate variables that correspond to this question, each with response options that contain the different vegetable types (1-16). Below is a picture of the raw data of the first 2 variables, so you can see how each of the 9 variables are structured. All I want to do is combine all the 1 responses across the 9 separate variables and then combine the responses 2-16 across the 9 separate variables. With the code below, the 1 responses are all correctly combined, but the problem is that the code is not capturing all the 2-16 response options across the 9 separate variables, it is only capturing the 2-16 response options for variable 8_7a in the first part of the code [else if 8_7a in (2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) and ignoring the rest of the following or statements, so I am not capturing the responses 2-16 on the rest of the other 8 variables. Why would this be occurring? Here is my code that I have tried: broccoli=.;
if 8_7A=1 OR 8_7B=1 OR 8_7C=1 OR 8_7d=1 or 8_7e=1 or 8_7f=1 or 8_7g=1 or 8_7h=1 or 8_7i=1 then broccoli=1;
else if 8_7a IN (2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) or 8_7B in (2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) or 8_7c in (2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) or 8_7d in (2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) or 8_7e in (2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) or 8_7f in (2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) or 8_7g in (2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) or 8_7h in (2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) or 8_7i in (2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) then broccoli=0;
else broccoli=.; Any help is appreciated!
... View more