Hello everyone. Would love some help on the following test data set!
How do I generate a variable employ1 which gives me for every state, whichever party has the maximum employment? And then a variable employ2 which gives me for every state, whichever party has the second highest employment? I made a small dataset to illustrate the example, my actual data set is much larger with a lot more states and parties.
For example, for state AP, employ1 would be BLUE and employ2 would be PINK, as in state AP, the BLUE party employs the most people and the PINK party employs the second highest number of people.
Similarly for state HP, employ1 would be PINK and employ2 would be RED.
Thanks in advance!
How do I generate a variable employ1 which gives me for every state, whichever party has the maximum employment? And then a variable employ2 which gives me for every state, whichever party has the second highest employment? I made a small dataset to illustrate the example, my actual data set is much larger with a lot more states and parties.
For example, for state AP, employ1 would be BLUE and employ2 would be PINK, as in state AP, the BLUE party employs the most people and the PINK party employs the second highest number of people.
Similarly for state HP, employ1 would be PINK and employ2 would be RED.
Thanks in advance!
Comment