BookmarkSubscribeRSS Feed
Jennahawk12
Calcite | Level 5

Does anyone know how to creat a boxplot with descending y axis mean values?  It seems the only options for descending is descending alphabetical by the xaxis classfication variable.


I am doing Proc Boxplot with the following code:

Proc Boxplot data=sw_glove;

    Plot (concentration)*Process;

By Descending Process;

Run;

I want descending Concentration values, grouped by Process (numeric), not descending process names (alpahbetic).

Another option would be to list out the x axis variable names in the descending value order, but this seems like a lot of meaningless work.

Thanks,

1 REPLY 1
Quentin
Super User

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;

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 1 reply
  • 922 views
  • 0 likes
  • 2 in conversation