'Life is after all a recursive summation, indeed     Let's do some Statistics!

Department of Civil and Environmental Engineering
Frank Batten College of Engineering and Technology
Old Dominion University
Norfolk, Virginia 23529-0241, USA
Tel) (757) 683-3753
Fax) (757) 683-5354


	
Return to CEE 700/800 Homepage
CEE 700/800 Access Counter
 
Go back to
SAS Source Page
Analysis of Variance (ANOVA)
SAS Source: ANOVA.SAS

Example

Suppose that an experiment was conducted to find an optimal manufacturing criterion for a synthetic fiber. It was suspected that the tensile strenth of the synthetic fiber is directly related to the percentage of cotton it contains. (of course, the stronger, the better)

The experiment used five levels of cotton percentage, and five replicates were run in random order.

Cotton
Percventage (%)
Observations
1 2 3 4 5
15 7 7 15 11 9
20 1217121818
25 14 18 18 19 19
30 1928221923
35 7 10 11 15 11

Close examine comments in the source for specific model options.

SAS Listing


OPTIONS LINESIZE=80;
TITLE1 'Simple ANOVA with Multiple Mean Comparisons';
TITLE2 'Response variable: Strength ';
TITLE3 'Treatment  : Cotton';
TITLE4 'Levels of treatment are 15, 20, 25, 30 and 35';
DATA FIBER;
INPUT COTTON STRENGTH  @@;
/* @@ means a loop in reading input variable sequence */
CARDS;
15 7  15 7  15 15 15 11 15 9
20 12 20 17 20 12 20 18 20 18
25 14 25 18 25 18 25 19 25 19
30 19 30 25 30 22 30 19 30 23
35 7  35 10 35 11 35 15 35 11
;
RUN;

/* Print the original data set                   */
PROC PRINT;
RUN;

/* Analysis of Variance (ANOVA)                  */
PROC ANOVA;
     CLASSES COTTON;
/* Dependent = Effects                           */
     MODEL  STRENGTH=COTTON;
     MEANS COTTON / DUNCAN SNK;
     MEANS COTTON / LSD TUKEY CLDIFF;
/* MEANS */
/* = Means of dependent variables for any effect, i.e., cotton */
/* DUNCAN */
/* = Duncan’s multiple-range test on all main effect means */
/* SNK */
/* = Student-Newman-Keuls multiple range test on all main effect means */
/* LSD */
/* = Fisher’s least-significant difference, i.e., paired t-test */
/* TUKEY */
/* = Tukey’s studentized range test on all main effect means */
/* CLDIFF */
/* = Calc. C.I. for all pairwise differences between means */
RUN;


/* Post-comparison of ANOVA method to GLM method  */
TITLE1 'GLM APPROACH TO THE SAME PROBLEM';
PROC GLM;
     CLASSES COTTON;
     MODEL STRENGTH=COTTON;
     MEANS COTTON / DUNCAN SNK LSD TUKEY;
/* Contrast = T.H.                                */
     CONTRAST 'C30 vs. C35'                   COTTON  0 0  0 -1  1;
     CONTRAST 'C15 and C25 vs. C30 and C35'   COTTON  1 0  1 -1 -1;
     CONTRAST 'C15 vs. C25'                   COTTON  1 0 -1  0  0;
     CONTRAST 'C15, C25, C30 and C35 vs. C20' COTTON -1 4 -1 -1 -1;
RUN;

SAS Listing


Above SAS source can be simplified into a skeleton source for a simple linear least-square regression.


OPTIONS LINESIZE=80;
TITLE1 'Simple ANOVA with Multiple Mean Comparisons';
TITLE2 'Response variable: Strength ';
TITLE3 'Treatment  : Cotton';
TITLE4 'Levels of treatment are 15, 20, 25, 30 and 35';
DATA FIBER;
INPUT COTTON STRENGTH  @@;
/* @@ means a loop in reading input variable sequence */
CARDS;
15 7  15 7  15 15 15 11 15 9
20 12 20 17 20 12 20 18 20 18
25 14 25 18 25 18 25 19 25 19
30 19 30 25 30 22 30 19 30 23
35 7  35 10 35 11 35 15 35 11
;
RUN;

/* Analysis of Variance (ANOVA)                  */
PROC ANOVA;
     CLASSES COTTON;
/* Dependent = Effects                           */
     MODEL  STRENGTH=COTTON;
     MEANS COTTON / DUNCAN;
RUN;


SAS User Guide (SUG) for Procedures (PROC) used in the Source

SUG ANOVA procedure
SUG GLM procedure
SUG PRINT procedure
Go back to
SAS Source Page

Return to CEE 700/800 Homepage Return to CEE 700/800 Homepage Move to the Top of this page