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!
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.
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.
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!
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?
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!
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.
Using valueattrs worked perfectly! Each name on the y axis is being displayed now!
Thanks!
Thank you! adjusting the height in addition to using valueattrs worked perfectly.
Thank you again for your help!
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.