Hi, In SGPLOT, I would probably do this by sorting the data, then using discreteorder=data on the axis statemetn, as below. proc sql;
create table shoes as
select region, sales, mean(sales) as mean
from sashelp.shoes
group by region
order by mean descending,region
;
quit;
title1 "discreteorder=data";
proc sgplot data=shoes;
vbox sales/category=region;
xaxis type=discrete discreteorder=data;
run;
title1;
Not sure the easiest way to do it with PROC BOXPLOT. If you do need a list of x-values for an x-statement, you could generate it with something like: 170 proc sql;
171 select distinct quote(trim(region)) , mean(sales) as mean
172 into :RegionList separated by " ", :dummy
173 from sashelp.shoes
174 group by region
175 order by mean descending
176 ;
177 quit;
178
179 %put &RegionList;
"Middle East" "United States" "Canada" "Central America/Caribbean" "Western Europe" "Eastern
Europe" "Pacific" "South America" "Africa" "Asia"
HTH, --Q;
... View more