options ls=65 ps=54;          /* linesize=65 pagesize=54 lines */
title 'Hardness Testing Experiment from Table 2-5 pg. 50';

* Read data into SAS from an external file;
filename raw '~/Montgomery/Data/tble2-5.dat';
data raw;
  infile raw;
  input tip1 tip2;
  diff=tip1-tip2;         /* create a new variable called diff */ 
run;

proc print data=raw;                         /* print the data */
run;
        Hardness Testing Experiment from Table 2-5 pg. 50       1
                                  08:02 Friday, December 19, 1997

                   OBS    TIP1    TIP2    DIFF

                     1      7       6       1 
                     2      3       3       0 
                     3      3       5      -2 
                     4      4       3       1 
                     5      8       8       0 
                     6      3       2       1 
                     7      2       4      -2 
                     8      9       9       0 
                     9      5       4       1 
                    10      4       5      -1 

* descriptive statistics and inference for diff;
proc univariate data=raw plot normal;  
  var diff;
run;
 
       Hardness Testing Experiment from Table 2-5 pg. 50       2
                                  08:02 Friday, December 19, 1997

                      Univariate Procedure
Variable=DIFF

                            Moments

         ***N                10  Sum Wgts         10
         ***Mean           -0.1  Sum              -1
         ***Std Dev    1.197219  Variance   1.433333***
            Skewness   -0.73814  Kurtosis   -0.87847
            USS              13  CSS            12.9
            CV         -1197.22  Std Mean   0.378594***
         ***T:Mean=0   -0.26414  Pr>|T|       0.7976***
            Num ^= 0          7  Num > 0           4
            M(Sign)         0.5  Pr>=|M|      1.0000
            Sgn Rank         -2  Pr>=|S|      0.6719
         ***W:Normal   0.828184  Pr<W         0.0312***


                        Quantiles(Def=5)

             100% Max         1       99%         1
              75% Q3          1       95%         1
              50% Med         0       90%         1
              25% Q1         -1       10%        -2
               0% Min        -2        5%        -2
                                       1%        -2
             Range            3                    
             Q3-Q1            2                    
             Mode             1                    


                            Extremes

               Lowest    Obs     Highest    Obs
                   -2(       7)        0(       8)
                   -2(       3)        1(       1)
                   -1(      10)        1(       4)
                    0(       8)        1(       6)
                    0(       5)        1(       9)


        Hardness Testing Experiment from Table 2-5 pg. 50       3
                                  08:02 Friday, December 19, 1997

                      Univariate Procedure

Variable=DIFF

        Stem Leaf                     #             Boxplot
           1 0000                     4             +-----+
           0                                        |     |
           0 000                      3             *-----*
          -0                                        |  +  |
          -0                                        |     |
          -1 0                        1             +-----+
          -1                                           |   
          -2 00                       2                |   
             ----+----+----+----+              


                         Normal Probability Plot              
      1.25+                             *  *  *+++ *          
          |                               ++++                
          |                     *  * *++++                    
          |                      ++++                         
          |                  *+++                             
          |              ++++                                 
          |          *+++ *                                   
     -2.25+     +++++                                         
           +----+----+----+----+----+----+----+----+----+----+
               -2        -1         0        +1        +2     


* Normal Probability Plot for diff;
proc rank data=raw out=qqplot normal=vw;
  var diff;
  ranks expected;
run;

proc plot data=qqplot vpct=50;
  plot diff*expected;
run;
 
       Hardness Testing Experiment from Table 2-5 pg. 50       4
                                  08:02 Friday, December 19, 1997

   Plot of DIFF*EXPECTED.  Legend: A = 1 obs, B = 2 obs, etc.
 
   1 +                                                    D
     |
     |
     |
     |
   0 +                               C
     |
DIFF |
     |
     |
  -1 +                     A
     |
     |
     |
     |
  -2 +         B
     --+----------+----------+----------+----------+----------+--
     -1.5       -1.0       -0.5        0.0        0.5        1.0
 
                        RANK FOR VARIABLE DIFF