Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
BOXCHART Statement

Example 32.2: Creating Various Styles of Box-and-Whisker Plots


See SHWBOX5 in the SAS/QC Sample Library

This example uses the flight delay data of the preceding example to illustrate how you can create box charts with various styles of box-and-whisker plots. For simplicity, the control limits are suppressed. The following statements create a chart, shown in Output 32.2.1, that displays skeletal box-and-whisker plots:

   title 'Analysis of Airline Departure Delays';
   symbol v=plus c=salmon;
   proc shewhart data=times limits=timelim ;
      boxchart delay * day /
         boxstyle = skeletal
         serifs
         stddeviations
         nolimits
         nohlabel
         nolegend
         cframe   = vligb
         cboxes   = dagr
         cboxfill = ywh;
         label delay = 'Delay in Minutes';
   run;

In a skeletal box-and-whisker plot, the whiskers are drawn from the quartiles to the extreme values of the subgroup sample. You can also request this style by omitting the BOXSTYLE= option, since this style is the default. The SERIFS option adds serifs to the whiskers (by default, serifs are omitted with the skeletal style). The NOLIMITS option suppresses the display of the control limits. The STDDEVIATIONS option specifies that \sigma is to be estimated from subgroup standard deviations rather than subgroup ranges (you should specify this option with sample sizes greater than 10 or when using the NOLIMITS option to create standard side-by-side box-and-whisker plots).

Output 32.2.1: BOXSTYLE=SKELETAL with Serifs
boxex2a.gif (5392 bytes)

The following statements request a box chart with schematic box-and-whisker plots:

   proc shewhart data=times limits=timelim ;
      boxchart delay * day /
         boxstyle  = schematic
         stddeviations
         nolimits
         nohlabel
         nolegend
         cframe   = vligb
         cboxes   = dagr
         cboxfill = ywh
         idcolor  = salmon;
      label delay = 'Delay in Minutes';
   run;

The chart is shown in Output 32.2.2. When BOXSTYLE=SCHEMATIC is specified, the whiskers are drawn to the most extreme points in the subgroup sample that lie within so-called "fences." The upper fence is defined as the third quartile (represented by the upper edge of the box) plus 1.5 times the interquartile range (IQR). The lower fence is defined as the first quartile (represented by the lower edge of the box) minus 1.5 times the interquartile range. Observations outside the fences are identified with a special symbol. The default symbol is a square, and you can specify the shape and color for this symbol with the IDSYMBOL= and IDCOLOR= options. Serifs are added to the whiskers by default. For further details, see the entry for the BOXSTYLE= option.

Output 32.2.2: BOXSTYLE=SCHEMATIC
boxex2b.gif (5320 bytes)

The following statements create a box chart with schematic box-and-whisker plots in which the observations outside the fences are labeled:

   proc shewhart data=times limits=timelim ;
      boxchart delay * day /
         boxstyle = schematicid
         stddeviations
         nolimits
         nohlabel
         nolegend
         llimits  = 20
         cboxes   = dagr
         cboxfill = ywh
         cframe   = vligb
         idcolor  = salmon;
      id reason;
      label delay = 'Delay in Minutes';
   run;

The chart is shown in Output 32.2.3. If you specify BOXSTYLE=SCHEMATICID, schematic box-and-whisker plots are displayed in which the value of the first ID variable (in this case, REASON) is used to label each observation outside the fences.

Output 32.2.3: BOXSTYLE=SCHEMATICID
boxex2c.gif (6026 bytes)

The following statements create a box chart with schematic box-and-whisker plots in which only the extreme observations outside the fences are labeled:

   proc shewhart data=times limits=timelim ;
      boxchart delay * day /
         boxstyle = schematicidfar
         stddeviations
         nolimits
         nohlabel
         nolegend
         cframe   = vligb
         cboxes   = dagr
         cboxfill = ywh
         idcolor  = salmon;
      id reason;
      label delay   = 'Delay in Minutes';
   run;

The chart is shown in Output 32.2.4. If you specify BOXSTYLE=SCHEMATICIDFAR, schematic box-and-whisker plots are displayed in which the value of the first ID variable is used to label each observation outside the lower and upper far fences. The lower and upper far fences are located IQR below the 25 th percentile and above the 75 th percentile, respectively. Observations between the fences and the far fences are identified with a symbol but are not labeled.

Output 32.2.4: BOXSTYLE=SCHEMATICIDFAR
boxex2d.gif (5540 bytes)

Other options for controlling the display of box-and-whisker plots include the BOXWIDTH=, BOXWIDTHSCALE=, CBOXES=, CBOXFILL=, and LBOXES= options. For details, see the corresponding entries in Chapter 46, "Dictionary of Options."

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.