options ls=65 ps=54; 
title 'Catalyst Experiment in Table 5-22 pg. 209';

* Read data into SAS from an external file;
filename raw '~/Montgomery/Data/tble5-22.dat';
data raw;
  infile raw;
  input trmt block response; 
run;

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

* Stage I and Stage II Analysis of RIBD;
proc glm data=raw;
  class trmt block;
  model response = block trmt / p;
  means trmt / duncan;
  lsmeans trmt / stderr tdiff pdiff;
  output out=temp p=fit r=resid student=stdresid;
run;

* Validation of Assumptions;

* Residual plots and Normal Probability plot;
proc rank data=temp out=checkass normal=vw;
  var resid;
  ranks expected;
run;

proc plot data=checkass vpct=50 hpct=50;
  plot stdresid*fit = '*' / vref=-2 2 vrefchar='-' box;
  plot stdresid*trmt = '*' / vref=-2 2 vrefchar='-' box;
  plot stdresid*block = '*' / vref=-2 2 vrefchar='-' box;
  plot expected*resid = '*' / box;
run;