BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
einstein
Quartz | Level 8

I'm trying to remove the whiskers from a boxplot, but can't seem to make it work.  And not all labels are being displayed on my y axis either.

Anyone have any suggestions on how to get rid of the whiskers and display all labels on the y axis?

I'm using SAS enterprise guide, V4.3

 

Here is my code:

 

symbol i=box25 /*no whiskers - but doesn't seem to work*/
interpol=boxt20 value=plus;
proc sgplot data=tem1;
hbox bed_dec / category=mdinitial extreme grouporder=ascending;
format bed_dec hhmm.;
xaxis label="Bed to Discharge, in hours" max=17000 interval=hour integer type=time notimesplit values=( 0 3600 7200 10800 14400 18000) ;
yaxis label="Physician Name" fitpolicy=thin display=all;

run;

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

You can hide the whiskers by setting their thickness=0.  Note, the SAS/GRAPH SYMBOL statement has no effect for SGPLOT.

Use the appropriate options to set the marker symbol for SGPLOT.  Please see product documentation.

Not sure what you mean by "Not all labels are being displayed on my y axis".  Only one y-axis label is shown.  Do you mean tick values?

It is useful to include the SAS (not EG) release you are using.  

 

proc sgplot data=sashelp.cars;
vbox horsepower / category=type whiskerattrs=(thickness=0);
run;

 

 I just noticed you have an HBOX.  Y axis tick values will be thinned if you have too many.  Depending on your SAS release, you can set the y-axis FITPOLICY=NONE.

View solution in original post

7 REPLIES 7
Jay54
Meteorite | Level 14

You can hide the whiskers by setting their thickness=0.  Note, the SAS/GRAPH SYMBOL statement has no effect for SGPLOT.

Use the appropriate options to set the marker symbol for SGPLOT.  Please see product documentation.

Not sure what you mean by "Not all labels are being displayed on my y axis".  Only one y-axis label is shown.  Do you mean tick values?

It is useful to include the SAS (not EG) release you are using.  

 

proc sgplot data=sashelp.cars;
vbox horsepower / category=type whiskerattrs=(thickness=0);
run;

 

 I just noticed you have an HBOX.  Y axis tick values will be thinned if you have too many.  Depending on your SAS release, you can set the y-axis FITPOLICY=NONE.

einstein
Quartz | Level 8

This worked - the whiskers are gone!  Thank you!

 

But the y-axis values (the physician names) are still not all appearing.  The FITPOLICY=NONE did not work in my version - SAS 9.3.

 

Thank you so much for your help though!

 

ballardw
Super User

Fitpolicy = thin removes some of the values so you may want to consider removing that. If there isn't enough room to show all of your values try stagger or staggerrotate. Or make the graphics display area larger with ODS graphics / height=   width=  ; set sizes large enough like 8in or 200cm but do include a unit.

 

Extreme in the hbox says to extend the whiskers, so may not be what you want.

You may have to delve into GTL and BOXPLOTPARM to provide more control, or possibly a different procedure.

 

If the whiskers are suppressed is your intent to do display the individual values instead of whiskers similar to outliers?

einstein
Quartz | Level 8

Where would you put the code STAGGER or STAGGERATE?

 

I suppressed the whiskers because I only want to show the boxplot itself.

 

I will try playing with the ODS graphics.

 

Thanks so much for all your help!

Jay54
Meteorite | Level 14

With SAs 9.3, your options are limited.  You can try setting the Y axis tick value attrs to a smaller font, and get more values displayed. 

 

proc sgplot data=sashelp.cars;
  hbox horsepower / category=make;
  yaxis valueattrs=(size=5);
run;

 

However, depending on the number of categories, this has its limits since you cannot reduce the font size below a certain minimum (I think 5 pt).  Anyway, with too many values they may become unreadable anyway.  The best option may be to increase the height of the graph, or page them out by some other classifier.  In the above case, you can use BY ORIGIN.  

 

proc sort data=sashelp.cars out=cars;
  by origin;

run;

 

proc sgplot data=cars;
  by origin;
  hbox horsepower / category=model;
run;

 

If your data does not have a classifier, you can add a classifier (say A) for every N categories,  Then use a BY A; in you code to create separate graphs for each value of the classifier.

einstein
Quartz | Level 8

Using valueattrs worked perfectly!  Each name on the y axis is being displayed now!

 

Thanks!

einstein
Quartz | Level 8

Thank you!  adjusting the height in addition to using valueattrs worked perfectly.

 

Thank you again for your help!

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 7 replies
  • 2825 views
  • 0 likes
  • 3 in conversation