Hi,

I would like to order variables after a reshape in descending order based on sys_tot. To do this, I used rank. The reshape is not working and giving the following error:
Error when values converted to variable names. Try encoding rank and setting original to label. I would like the encoded labels of sys_id to be the variable labels of rank after the reshape. I tried using labmask and I got the error below.

Code:

egen rank = rank (sys_tot), field //generate rank for sys tot greatest to least
tostring rank, replace
//labmask rank, values(sys_id) // error: sys_id not constant within groups of rank
supershape wide d_, i(mdc mdc_desc) j(rank) labels(sys_id) //mdc long; provider wide

Please advice.

Thank you!