turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS/GRAPH and ODS Graphics
- /
- Labels for median values in a box plot

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-08-2015 09:02 PM

Hello,

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);

run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to aellman

04-09-2015 09:55 AM

Hello,

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

http://blogs.sas.com/content/graphicallyspeaking/2011/11/10/it-pays-to-be-discrete/

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.

Thanks.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to djrisks

04-14-2015 08:05 PM

Thanks! I'll give it a try.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to aellman

04-09-2015 01:16 PM

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.