Hello,
I am working with a data set that looks like this:
Each row represents one school's response to a survey, with each column representing that school's response to each survey question.
I need to generate new variables that show the survey question that received the highest score and the value of that survey question for each school. Furthermore, I need to generate new variables that show the survey question that received the second highest score and the value of that survey question for each school. To clarify, I'd like to be able to create the table below:
I searched through previous Statalist postings and on some other websites to try to find the best way to go about doing this. One source suggested using reshape then sort then reshape again. The resulting data set would have all of the items for each school organized from lowest score to highest score, but I would not have any way of identifying which item corresponds to each score.
Thank you for any guidance you can provide!
Best,
Anne
I am working with a data set that looks like this:
ID | Item1 | Item2 | Item3 | Item4 | Item5 | Item6 | Item7 | Item8 | Item9 |
1 | 20.2 | 14.6 | 37.0 | 82.7 | 16.0 | 82.1 | 71.1 | 76.2 | 78.0 |
2 | 12.1 | 6.7 | 35.0 | 76.7 | 5.0 | 90.2 | 93.3 | 76.7 | 75.0 |
3 | 72.8 | 22.0 | 45.6 | 91.8 | 25.6 | 96.1 | 88.1 | 96.0 | 85.8 |
Each row represents one school's response to a survey, with each column representing that school's response to each survey question.
I need to generate new variables that show the survey question that received the highest score and the value of that survey question for each school. Furthermore, I need to generate new variables that show the survey question that received the second highest score and the value of that survey question for each school. To clarify, I'd like to be able to create the table below:
ID | Item1 | Item2 | Item3 | Item4 | Item5 | Item6 | Item7 | Item8 | Item9 | Highest Item | Highest Item Value | 2nd Highest Item | 2nd Highest Item Value | Lowest Item | Lowest Item Value | 2nd Lowest Item | 2nd Lowest Item Value |
1 | 20.2 | 14.6 | 37.0 | 82.7 | 16.0 | 82.1 | 71.1 | 76.2 | 78.0 | Item4 | 82.7 | Item6 | 82.1 | Item2 | 14.6 | Item5 | 16.0 |
2 | 12.1 | 6.7 | 35.0 | 76.7 | 5.0 | 90.2 | 93.3 | 76.7 | 75.0 | Item7 | 93.3 | Item6 | 90.2 | Item5 | 5.0 | Item2 | 6.7 |
3 | 72.8 | 22.0 | 45.6 | 91.8 | 25.6 | 96.1 | 88.1 | 96.0 | 85.8 | Item6 | 96.1 | Item8 | 96.0 | Item2 | 22.0 | Item5 | 25.6 |
I searched through previous Statalist postings and on some other websites to try to find the best way to go about doing this. One source suggested using reshape then sort then reshape again. The resulting data set would have all of the items for each school organized from lowest score to highest score, but I would not have any way of identifying which item corresponds to each score.
Thank you for any guidance you can provide!
Best,
Anne
Comment