Hello,
I am trying to figure out how to generate a new variable that will tell me if (e.g.) two values appear in a row, in any two of five different variables. The data are structured like this:
v1 v2 v3 v4 v5
1 . 2 . 3 . 8 . 10
I want to create a new variable where:
0=1 & 2 occur in row
1=only 1 appears in row
2=only 2 appears in row
3=neither 1 nor 2 appear in row
So in my above example, newvar=0.
My assumption was that I would be able to accomplish this using inlist, but it seems like inlist will not work with v* (i.e., it will only let me specify a single variable, not a list of variables). Does anyone have any suggestions?
Thank you! Stacy
I am trying to figure out how to generate a new variable that will tell me if (e.g.) two values appear in a row, in any two of five different variables. The data are structured like this:
v1 v2 v3 v4 v5
1 . 2 . 3 . 8 . 10
I want to create a new variable where:
0=1 & 2 occur in row
1=only 1 appears in row
2=only 2 appears in row
3=neither 1 nor 2 appear in row
So in my above example, newvar=0.
My assumption was that I would be able to accomplish this using inlist, but it seems like inlist will not work with v* (i.e., it will only let me specify a single variable, not a list of variables). Does anyone have any suggestions?
Thank you! Stacy
Comment