I would like to plot the mean of a variable, with 2 stdev and sort the data by the y variable (lowest value to largest value). So the Y axis would have labels Domestic and Foreign where foreign would be higher on the y than domestic. In this case, it is easy to switch the numerical value, but in my data I have 102 categories.
My only work around is creating a new categorical variable from scratch sorted on the y but I cannot get the labels to work from the old categorical variable. I was hoping there was an option but sort() does not seem to work for this.
sysuse auto
collapse (mean) y = price (semean) se_y = price, by(foreign)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
twoway (scatter foreign y) (rcap yu yl foreign, horizontal)
My only work around is creating a new categorical variable from scratch sorted on the y but I cannot get the labels to work from the old categorical variable. I was hoping there was an option but sort() does not seem to work for this.
sysuse auto
collapse (mean) y = price (semean) se_y = price, by(foreign)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
twoway (scatter foreign y) (rcap yu yl foreign, horizontal)
Comment