BookmarkSubscribeRSS Feed
Fluorite | Level 6


I have created box plots using SAS 9.3 and SGPLOT as below. I would like to label the median values on the graph.  Is this possible?  I'm flexible on where the labels are - inside the box or to the side is fine.  If this isn't possible then, using v 9.3, is it possible to create an axis table for the median values?

I am using ODS to output to PDF and HTML.

Thank you in advance!

proc sgplot data=analysis_data;

            vbox admin_qty_12months/category=year;

    xaxis label="Index Year";

    yaxis label="Total administrations" grid values = (0 to 100 by 20);


Barite | Level 11


You could use the discrete offset options or the blockplot statment which are explained on the Graphically speaking blog linked below.

Although, with these methods and because you want to produce a boxplot you will need to use GTL instead of SGPLOT. You will also need to create a column that contains the median of each year.

Please let me know if you have any questions.


Fluorite | Level 6

Thanks!  I'll give it a try.

Meteorite | Level 14

SGPLOT VBox does not allow overlays with other plots to add labels.  But, with SAS 9.3, your best bet is to use SGANNOTATE to label the median values.

With GTL, you have the option to display the statistics below the box plot.  You can request only median if you want.  Or, you can use Scatterplot with DataLabel and DataLabelPosition to overlay the median value in the graph. Make the markers themselves of size=0.




The early bird rate has been extended! Register by March 18 for just $695 - $100 off the standard rate.


Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 


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
  • 3 replies
  • 3 in conversation