options ls=65 ps=54;              
title 'Rocket Propellant Problem from Table 5-20 pg. 206';

* Read data into SAS from an external file;
filename raw '~/Montgomery/Data/tble5-20.dat';
data raw;
  infile raw;
  input rowblock colblock trmt $ grkblock $ response;     
run;                                  

* Print the data;
proc print data=raw;         
run;

* Statistical analysis for pxp Graeco-Latin Square Design;
proc glm data=raw;              
  class rowblock colblock grkblock trmt;
  model response=rowblock colblock grkblock trmt;
  means trmt / lsd alpha=0.05;
  output out=temp p=fit r=resid student=stdresid; 
run;

* Model adequacy checking (Residual Analysis);        
proc rank data=temp out=checkass normal=vw;
  var resid;
  ranks expected;
run;

proc print data=checkass;
  var response fit resid stdresid expected;
run;

proc plot data=checkass vpct=50 hpct=50;
  plot response*trmt = '*' /box;                  /* Plot of raw data
*/
  plot expected*resid = '*' / box;                /* Normal
Probability Plot */
  plot stdresid*fit = '*' / vref=-2 2 vrefchar='-' box;        /*
Homogenity of
  variance and interaction between blocks and treatments */
  plot stdresid*trmt = '*' / vref=-2 2 vrefchar='-' box;       /*
Homogenity of 
  variance among treatment groups and outlier detection */
  plot stdresid*rowblock = '*' / vref=-2 2 vrefchar='-' box;   /*
Homogenity of 
  variance among rowblock and outlier detection */
  plot stdresid*colblock = '*' / vref=-2 2 vrefchar='-' box;   /*
Homogenity of
  variance among colblock and outlier detection */
  plot stdresid*grkblock = '*' / vref=-2 2 vrefchar='-' box;   /*
Homogenity of
  variance among grkblock and outlier detection */
run;

proc univariate data=checkass plot normal;
  var resid;
run;