I have index scores small area data and am calculating higher area based box plots using this data. When I chart my data it is arranged in alphabetical order. I want the higher level areas ordered by their box plot average (mean_all). I have SAS 7.1 and 'CATEGORYORDER=RESPASC' appears to do nothing? Am I doing something wrong - are there any suggestions? I have a total of 150 areas I'm doing box plots for so not sure formatting is something I would want to do with this many areas. I want them ordered from highest to smallest number for 'mean_all'. The required input file is included here as suburb_scores.
Thanks
Ben
proc sgplot data=finalresult_2 dattrmap=attrmap noborder;
hbox pca_all / category=ced lineattrs=(pattern=solid) whiskerattrs=(pattern=solid) whiskerpct=0
meanattrs=(color=black symbol=Plus) medianattrs=(color=black ) attrid=myid CATEGORYORDER=RESPASC;
by gcc2;
yaxistable mean_all / location=inside valueattrs=(size=6) separator labelattrs=(size=6) stat=mean ;
Hi @MicrosimBen and welcome to the SAS Support Communities!
Instead of CATEGORYORDER= use a YAXIS statement (in the PROC SGPLOT step) with the DISCRETEORDER= option:
yaxis discreteorder=data;
As a preliminary step, you need to sort the input dataset (or create a sorted view) by descending mean_all within the BY groups so that discreteorder=data leads to the intended sort order:
proc sort data=finalresult_2;
by gcc2 descending mean_all;
run;
You are my sunshine, my only sunshine! Tks!
Thanks a lot that's fantastic!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.