# SAS Workshop: ANOVAs

ANOVAs or Analysis of Variance is one of the “classic” or standard statistical analyses that you will complete at one time or another during your research career.  The statistical methodology behind the ANOVAs has changed a great deal over the past 40-50 years and SAS has done its part by creating new PROCs to match the statistical advances.

This part of the SAS Workshop will start by reviewing the SAS PROCedures that were created and used over the years.  This will give you a better sense as to why we are using the newest PROCedure GLIMMIX and will hopefully provide you insight as to why some researchers are still using the older PROCedures GLM or MIXED.

## History of ANOVA analyses in SAS

1966 – SAS is released with Proc ANOVA, which is to be used with:

• balanced data ONLY!
• FIXED effects ONLY!
• NOTE from SAS Online Docs: “Caution:If you use PROC ANOVA for analysis of unbalanced data,you must assume responsibility for the validity of the results.

1976 – SAS released Proc GLM

• balanced (Type I SS) and unbalanced (Type III SS)
• RANDOM statement introduced – provides EMS (expected mean squares equations, but you need to do the calculations!)

1992 – Proc MIXED

• RANDOM statement incorporated
• REPEATED statement introduced
• “Normally distributed” data ONLY
• linear effects

1992 – Proc GENMOD

• Non-normal data
• Fixed effects ONLY

xxxx? – Proc NLMIXED

• normal, binomial, Poisson distributions
• nonlinear effects

2005 – Proc GLIMMIX

• Proc MIXED
• Proc NLMIXED
• Non-normal data

## Randomized Complete Block Design (RCBD)

We will start by analyzing the data collected from a small RCBD trial.  There were 4 blocks, where 6 treatments were randomly assigned to each.  To run these analyses, please copy and paste the following code into your SAS program.  There may be edits that you will need to make when you paste into your program.

Data rcbd;
input block trmt Nitrogen;
datalines;
1 1 34.98
1 2 40.89
1 3 42.07
1 4 37.18
1 5 37.99
1 6 34.89
2 1 41.22
2 2 46.69
2 3 49.42
2 4 45.85
2 5 41.99
2 6 50.15
3 1 36.94
3 2 46.65
3 3 52.68
3 4 40.23
3 5 37.61
3 6 44.57
4 1 39.97
4 2 41.9
4 3 42.91
4 4 39.2
4 5 40.45
4 6 43.29
;
Run;

Run this data and use a Proc Print to ensure that the data was read correctly.

Once we have the data in our SAS program, let’s start with PROC GLM:

/* Proc GLM Statements */
Proc glm data=rcbd;
class block trmt;
model Nitrogen = block trmt;
random block;
title “Proc GLM Results”;
Run;
Quit;

Here is a PDF copy of the output created by the above code.  I will review the output and the code that is used to generate it during the workshop.

Let’s move onto PROC MIXED:

/* Proc MIXED Statements with an LSMEANS for treatment differences */
Proc mixed data=rcbd;
class block trmt;
model Nitrogen = trmt;
random block;
title “Proc MIXED Results”;
Run;

Here is a PDF copy of the output created by the above code.  I will review the output and the code that is used to generate it during the workshop.

Now let’s do the same analysis for a third time using PROC GLIMMIX.  The code is:

/* Proc GLIMMIX Statements with an LSMEANS for treatment differences */
Proc glimmix data=rcbd;
class block trmt;
model Nitrogen = trmt;
random block;
title “Proc GLIMMIX Results”;
Run;

Here is a PDF copy of the output created by the above code.  I will review the output and the code that is used to generate it during the workshop.

So…  if you have used PROC MIXED in the past, moving to GLIMMIX is easy and highly recommended!