Macro examples for ST553

Original SAS code

proc format;
  value timefmt  1="Early" 2="Optimal" 3="Late";
  value trtfmt  1="None" 2="0.5 lbs/acre";

data data1;
  input block time trtmt N @@;
  format time timefmt. trtmt trtfmt.;
cards;
1 1 1 21.4 2 1 1 21.3 3 1 1 34.9
1 1 2 54.8 2 1 2 47.9 3 1 2 40.1
1 2 1 40.8 2 2 1 42.7 3 2 1 41.8
1 2 2 56.2 2 2 2 56.8 3 2 2 57.9
1 3 1 53.2 2 3 1 44.8 3 3 1 57.8
1 3 2 57.7 2 3 2 54.0 3 3 2 62.0
;


*** Model and residual plot ***;

proc glm data=data1 order=data;
  class block time trtmt;
  model N = time trtmt time*trtmt block;
  lsmeans time trtmt time*trtmt / stderr;
  output out=resids r=resid p=pred;
title1 h=1.25 "Full model: N = time trtmt time*trtmt block";
run; quit;

proc univariate data=resids noprint;
  var resid;
  qqplot resid / normal;

proc gplot data=resids;
  plot resid*pred;
  symbol v=circle;
title2 "Residual plot";

run; quit;


*** Reduced model ***;

proc glm data=data1 order=data;
  class block time trtmt;
  model N = time trtmt block;
  lsmeans time trtmt / stderr;
  output out=resids r=resid p=pred;
title1 h=1.25 "Reduced model: N = time trtmt block";
run; quit;

proc univariate data=resids noprint;
  var resid;
  qqplot resid / normal;

proc gplot data=resids;
  plot resid*pred;
  symbol v=circle;
title2 "Residual plot";

run; quit;

*** Time only model ***;

proc glm data=data1 order=data;
  class block time;
  model N = time  block;
  lsmeans time  / stderr;
  output out=resids r=resid p=pred;
title1 h=1.25 "Reduced model: N = time block";
run; quit;

proc univariate data=resids noprint;
  var resid;
  qqplot resid / normal;

proc gplot data=resids;
  plot resid*pred;
  symbol v=circle;
title2 "Residual plot";

run; quit;

First, Second, Third, Fourth macro examples.