BookmarkSubscribeRSS Feed
Calcite | Level 5

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.





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 ;

Jade | Level 19

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;


Fluorite | Level 6

You are my sunshine, my only sunshine! Tks!

Calcite | Level 5

Thanks a lot that's fantastic!



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

How to Concatenate Values

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.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 3 in conversation