|
|
I inherited some data from a survey that asked respondents to rank the
top three concepts from among 11 concepts.
The data are encoded in eleven contiguous columns, one for each concept,
named Q8concept1 to Q8concept11.
I've included a sample data file that can be interpreted as follows.
Respondent 101 thought concept 10 was the best concept so a 1 was placed
in the Q8concept10 column for case 101.
Respondent 101 thought concept 5 was the second best concept so a 2 was
placed in the Q8concept5 column for case 101.
Respondent 101 thought concept 2 was the third best concept so a 3 was
placed in the Q8concept2 column for case 101.
I need to create a new variable that identifies in a single variable
which of the 11 concepts was ranked number 1 for each case.
Thus, the new variable will contain a 10 for respondent 101, a 3 for
respondent 102, a 3 for respondent 103, a 5 for respondent 104, and so
forth.
I guess I need to create a vector to loop through Q8concept1 to
Q8concept 11 to identify which of those variables contains the minimum
value for each case, but I don't know how to write the code to create
the new variable and place a value of 1 to 11 in it to denote which of
the 11 concepts was ranked number 1.
Does anyone know how to write such a macro? Thanks for the help.
DATA LIST LIST (",") / id Q8concept1 to Q8concept11.
BEGIN DATA
101,,3,,,2,,,,,1,,
102,,,1,,,3,,2,,,,
103,2,,1,,,3,,,,,,
104,,,3,,1,,,2,,,,
105,,1,,,,,3,,,,2,
106,,1,,,,,2,,,,3,
107,,,,,3,2,1,,,,,
END DATA.
|