Data visualization with SAS programming

Create Box plots Using only Summaries

Posts: 1

Create Box plots Using only Summaries

I need to create boxplots with only 5 number summaries. Is this possible? The full dataset is not available.
Posts: 1,674

Re: Create Box plots Using only Summaries

One way would be by modifying the great macro available here:

and replace the summarisation steps by your own data.
SAS Employee
Posts: 980

Re: Create Box plots Using only Summaries

If you only have the summary statistics (rather than the raw data), you might want to use "proc boxplot" (which I believe is technically part of SAS/Stat rather than SAS/Graph - but I think most users usually have both these procs anyway...)

With proc boxplot, you can use the outhistory= option to create a data set containing the summary statistics for each bar, or use the history= option to use a data set containing summary statistics (rather than using data= with the raw data).

Creating the 'history' data sets is a little tricky (how to name the variables, and such) - I'd recommend running proc boxplot, and looking at the resulting 'outhistory' data set, and then using that as the starting point for your data set.

Here's a small sample I happened to have, which demonstrates how to use proc boxplot with a history= data set (hopefully the long data lines won't wrap badly):

data hubout;
input hub $ 1-14 revenuel revenue1 revenuex revenuem revenue3 revenueh revenuen;
Frankfurt 10717.43 45549.06 558199.30 171813.74 433385.93 3460389.08 12
London 16267.52 48802.57 677813.43 257026.85 574650.23 3743156.90 12
New York 33491.96 60955.36 1116398.59 401903.49 762946.80 7449951.09 12
San Francisco 0.00 45214.14 717684.81 215736.05 653667.32 4340557.73 12
Sydney 4353.95 32654.66 518327.92 141814.52 577209.97 3537899.04 12
Tokyo 2392.28 25358.20 398713.78 108370.41 275112.51 2984133.44 12

proc boxplot history=hubout;
plot revenue*hub;
Occasional Contributor
Posts: 5

Re: Create Box plots Using only Summaries

Apparently the following options do not work with 'History' (a summary data set):

  .Boxstyle = Schmatic


I desperately need both options to work with my summary data.

Super User
Posts: 11,134

Re: Create Box plots Using only Summaries

If your data contains values and counts of values this is more likely to be possible. Or if you have the mean, limits of the IQR and the limits for the whiskers it may be possible with annotate data sets. What kind of summarized data do you actually have? What do the 5 value represent? And what should the final plots look like?

Occasional Contributor
Posts: 5

Re: Create Box plots Using only Summaries














Occasional Contributor
Posts: 5

Re: Create Box plots Using only Summaries

The Box Plot should look like the following:

See "Just Enough SAS", "A Quick-Start Guide to SAS for Engineers", by Robert A. Rutledge,

Copyright 2009, SAS Institute, Inc. Figure 5.2, Page nbr 117.

This is a notched box plot.  The only difference would be I need the Schematic box plot instead of the Skeletal (shown in Figure 5.2).

Occasional Contributor
Posts: 5

Re: Create Box plots Using only Summaries

I am using the following procedure:

SAS/STAT(R) 9.22 User's Guide

The only difference is I need a Schematic type and I need it to be noched so I can perform a visual comparison of the medians.

Super User
Posts: 19,171

Re: Create Box plots Using only Summaries

The notched part works fine, the boxstyle option does not, but I can't visually see the difference from the example.

So perhaps post your code that isn't working, IN A NEW THREAD. Preferably linked back to this one. 

Occasional Contributor
Posts: 5

Re: Create Box plots Using only Summaries

I have learned that, with the standard 'History=' summary, one can't create a 'Schematic' style box plot because the Schematic style needs outlier data (not in the summary).

However with a 'BOX= input data (instead of 'History= input data') you can get both notched
and schematic. The BOX= data set must contain more data than the simpler
HISTORY= data set, though. It is not just a matter of reshaping from HISTORY=
to BOX=. If you only have the summary data that is found in a HISTORY= data set
then there is nothing you can do. You must have the values of the low and high
whiskers. These are the smallest and largest values in the data set that fall
within the fences. In addition you must have all the individual data points that
fall beyond the whiskers. These are the additional components of a schematic
box plot, and these are not typical summary statistics.

I think I am all set for now.  Thank you for quick and thorough response.

Super User
Posts: 19,171

Re: Create Box plots Using only Summaries

You're not the original OP, its better if you start a new thread.

Can you explain your issue in detail please. For example, you have a 7 not 5 numbers summary.

Ask a Question
Discussion stats
  • 10 replies
  • 6 in conversation