Hello,
I am trying to create a new variable if another numeric variable contains a specific value. From a survey, the respondent could select any option that applies. This creates a variable that contains a series of numbers (1, 123, 234, 12345, etc.). Like below:
Var1
1
12
145
467
2567
I'd like to create new variables so I can count how many times each value was selected (so how many times did respondents select the first option (which will be recorded as a 1). So, in this case, the first option was selected 3 times. So, something like:
generate option1 = 0; replace option1 = 1 if Var1 [contains the number 1]
Thank you.
I am trying to create a new variable if another numeric variable contains a specific value. From a survey, the respondent could select any option that applies. This creates a variable that contains a series of numbers (1, 123, 234, 12345, etc.). Like below:
Var1
1
12
145
467
2567
I'd like to create new variables so I can count how many times each value was selected (so how many times did respondents select the first option (which will be recorded as a 1). So, in this case, the first option was selected 3 times. So, something like:
generate option1 = 0; replace option1 = 1 if Var1 [contains the number 1]
Thank you.
Comment