The UNIVARIATE Procedure

Example 4.16 Creating a Two-Way Comparative Histogram

This example illustrates how to create a two-way comparative histogram. Two suppliers (A and B) provide disk drives for a computer manufacturer. The manufacturer measures the disk drive opening width to determine whether there has been a change in variability from 2002 to 2003 for each supplier.

The following statements save the measurements in a data set named Disk. There are two classification variables, Supplier and Year, and a user-defined format is associated with Year.

   proc format ;
      value mytime  1 = '2002' 2 = '2003';

   data Disk;
      input @1 Supplier $10. Year Width;
      label Width = 'Opening Width (inches)';
      format Year mytime.;
   datalines;
   Supplier A   1   1.8932
       .        .    .
   Supplier B   1   1.8986
   Supplier A   2   1.8978
       .        .    .
   Supplier B   2   1.8997
   ;

The following statements create the comparative histogram in Output 4.16.1:

title 'Results of Supplier Training Program';
ods graphics off;
proc univariate data=Disk noprint;
   class Supplier Year / keylevel = ('Supplier A' '2003');
   histogram Width / intertile  = 1.0
                     vaxis      = 0 10 20 30
                     ncols      = 2
                     nrows      = 2;
run;

The KEYLEVEL= option specifies the key cell as the cell for which Supplier is equal to 'SUPPLIER A' and Year is equal to '2003.' This cell determines the binning for the other cells, and the columns are arranged so that this cell is displayed in the upper left corner. Without the KEYLEVEL= option, the default key cell would be the cell for which Supplier is equal to 'SUPPLIER A' and Year is equal to '2002'; the column labeled '2002' would be displayed to the left of the column labeled '2003.'

The VAXIS= option specifies the tick mark labels for the vertical axis. The NROWS=2 and NCOLS=2 options specify a $2 \times 2$ arrangement for the tiles. Output 4.16.1 provides evidence that both suppliers have reduced variability from 2002 to 2003.

Output 4.16.1: Two-Way Comparative Histogram

Two-Way Comparative Histogram


A sample program for this example, uniex10.sas, is available in the SAS Sample Library for Base SAS software.