I have the following dataset that I would like to reshape from wide to long. I want the final dataset to contain a row for each respondent's ranking of each individual candidate in terms of favorability--i.e. for respondent 1, a row with fav_biden_2019Nov, fav_sanders_2019Nov, etc. I tried -reshape long fav, i(id) j(candidate)- and received the following 498 error: "variable candidate contains all missing values." Is there something I am missing?
I would also like the wide data to contain a dummy indicating whether that particular candidate was the respondent's choice for magicdempres_2019Nov, and I would appreciate any advice on how to go about that!
Thank you in advance!
I would also like the wide data to contain a dummy indicating whether that particular candidate was the respondent's choice for magicdempres_2019Nov, and I would appreciate any advice on how to go about that!
Thank you in advance!
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte(fav_biden_2019Nov fav_sanders_2019Nov fav_warren_2019Nov fav_harris_2019Nov) float id int magicdempres_2019Nov 2 2 1 2 1 4 1 3 1 2 2 2 2 2 1 1 3 1 1 1 1 2 4 999 2 3 1 1 5 1 1 1 1 1 6 1 3 2 1 2 7 1 2 2 1 2 8 16 4 4 5 5 9 999 1 1 1 2 10 2 4 2 2 4 11 999 4 4 4 4 12 999 4 4 4 4 13 999 4 4 4 4 14 999 4 3 4 4 15 999 5 2 1 2 16 1 2 2 1 1 17 1 3 3 2 3 18 4 4 4 4 4 19 999 2 2 1 3 20 4 end label values fav_biden_2019Nov Q8_f_2019Nov label def Q8_f_2019Nov 1 "Very favorable", modify label def Q8_f_2019Nov 2 "Somewhat favorable", modify label def Q8_f_2019Nov 3 "Somewhat unfavorable", modify label def Q8_f_2019Nov 4 "Very unfavorable", modify label def Q8_f_2019Nov 5 "Don't know", modify label values fav_sanders_2019Nov Q8_g_2019Nov label def Q8_g_2019Nov 1 "Very favorable", modify label def Q8_g_2019Nov 2 "Somewhat favorable", modify label def Q8_g_2019Nov 3 "Somewhat unfavorable", modify label def Q8_g_2019Nov 4 "Very unfavorable", modify label values fav_warren_2019Nov Q8_h_2019Nov label def Q8_h_2019Nov 1 "Very favorable", modify label def Q8_h_2019Nov 2 "Somewhat favorable", modify label def Q8_h_2019Nov 4 "Very unfavorable", modify label def Q8_h_2019Nov 5 "Don't know", modify label values fav_harris_2019Nov Q8_i_2019Nov label def Q8_i_2019Nov 1 "Very favorable", modify label def Q8_i_2019Nov 2 "Somewhat favorable", modify label def Q8_i_2019Nov 3 "Somewhat unfavorable", modify label def Q8_i_2019Nov 4 "Very unfavorable", modify label def Q8_i_2019Nov 5 "Don't know", modify label values magicdempres_2019Nov Q16_2019Nov label def Q16_2019Nov 1 "Elizabeth Warren", modify label def Q16_2019Nov 2 "Joe Biden", modify label def Q16_2019Nov 4 "Pete Buttigieg", modify label def Q16_2019Nov 16 "Joe Sestak", modify label def Q16_2019Nov 999 "not asked", modify
Comment