BOXCHART Statement: SHEWHART Procedure

Example 17.2 Creating Various Styles of Box-and-Whisker Plots

See SHWBOX5 in the SAS/QC Sample LibraryThis 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 17.2.1, that displays skeletal box-and-whisker plots:

ods graphics off;
title 'Analysis of Airline Departure Delays';
proc shewhart data=Times limits=Timelim ;
   boxchart Delay * Day /
      boxstyle = skeletal
      serifs
      nolimits
      nohlabel
      nolegend;
   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.

Output 17.2.1: BOXSTYLE=SKELETAL with Serifs

BOXSTYLE=SKELETAL with Serifs


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

title 'Analysis of Airline Departure Delays';
proc shewhart data=Times limits=Timelim ;
   boxchart Delay * Day /
      boxstyle = schematic
      nolimits
      nohlabel
      nolegend;
   label Delay = 'Delay in Minutes';
run;

The chart is shown in Output 17.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 BOXSTYLE= in Dictionary of Options: SHEWHART Procedure.

Output 17.2.2: BOXSTYLE=SCHEMATIC

BOXSTYLE=SCHEMATIC


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

title 'Analysis of Airline Departure Delays';
proc shewhart data=Times limits=Timelim ;
   boxchart Delay * Day /
      boxstyle = schematicid
      llimits  = 20
      nolimits
      nohlabel
      nolegend;
   id Reason;
   label Delay = 'Delay in Minutes';
run;

The chart is shown in Output 17.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 17.2.3: BOXSTYLE=SCHEMATICID

BOXSTYLE=SCHEMATICID


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

title 'Analysis of Airline Departure Delays';
proc shewhart data=Times limits=Timelim ;
   boxchart Delay * Day /
      boxstyle = schematicidfar
      nolimits
      nohlabel
      nolegend;
   id Reason;
   label Delay = 'Delay in Minutes';
run;

The chart is shown in Output 17.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 $3\times $IQR below the 25th percentile and above the 75th percentile, respectively. Observations between the fences and the far fences are identified with a symbol but are not labeled.

Output 17.2.4: BOXSTYLE=SCHEMATICIDFAR

BOXSTYLE=SCHEMATICIDFAR


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 Dictionary of Options: SHEWHART Procedure.