Hi Statalisters,
I'm trying to graph a stacked bar graph with each of the categories sorted in order of highest percentage to the smallest. Does anyone know how best to deal with this? Example data here
The -sort- option command isn't working for me following the below code
Thanks
I'm trying to graph a stacked bar graph with each of the categories sorted in order of highest percentage to the smallest. Does anyone know how best to deal with this? Example data here
Code:
clear input byte cat hdl_1 hdl_2 hdl_3 hdl_4 hdl_5 hdl_6 hdl_7 hdl_8 hdl_9 hdl_10 hdl_11 hdl_12 hdl_13 hdl_14 hdl_15 hdl_16 1 1.524952 19.75993 18.82018 6.359863 4.816993 0 15.50487 3.358603 17.13577 2.528465 1.368276 1.073384 2.954223 0 .2096547 4.452342 2 .9871029 16.283 20.67916 5.465534 5.295229 0 13.42496 2.838352 25.91014 2.068441 1.36044 .5245776 1.783914 .0988639 0 3.128761 3 1.203603 17.68257 19.93086 5.825528 5.102724 0 14.26219 3.047768 22.37819 2.253614 1.363594 .7454886 2.254999 .0590682 .0843923 3.661542 end label values cat catl label def catl 1 "Monday", modify label def catl 2 "Wednesday", modify label def catl 3 "Friday", modify
Code:
gr bar hdl_1- hdl_16, over(cat, sort(#)) stack percent blabel(bar, position(center) format(%4.0f))
Comment