Published on :
Statistical CREATION_INTERNE

Example 5 for PROC ANOVA

This code is also available in: Deutsch Español Français
Awaiting validation
The script initializes a dataset named 'Barley' using inline data (datalines), simulating a four-replicate strip-split plot experiment. The factors studied are Replication (Rep), Soil Type (Soil, 3 levels), Fertilizer Type (Fertilizer, 4 levels), and the presence/absence of Calcium (Calcium, 2 levels). The PROC ANOVA procedure is then used to model the yield ('Yield') as a function of these factors, including appropriate interactions and replication terms for a strip-split plot analysis. Several specific hypothesis tests are defined to evaluate the effects of the different factors and their interactions, using the correct error terms. Finally, means for different factor combinations are calculated and displayed.
Data Analysis

Type : CREATION_INTERNE


The 'Barley' dataset is created directly within the SAS script using a DATA step and the DATALINES statement. The data represents yields measured for various combinations of replications, soil types, fertilizer types, and calcium levels, structured for a strip-split plot experimental design.

1 Code Block
DATA STEP Data
Explanation :
This block uses a DATA step to create the 'Barley' dataset. It generates an experimental design by looping through the variables Rep (replication), Soil, Fertilizer, and Calcium. The `input Yield @;` statement sequentially reads yield values from the DATALINES statement, and the `output;` statement writes an observation for each factor combination. The title 'Strip-split Plot' is added to the SAS output.
Copied!
1title1 'Strip-split Plot';
2DATA Barley;
3 DO Rep=1 to 4;
4 DO Soil=1 to 3; /* 1=d 2=h 3=p */
5 DO Fertilizer=0 to 3;
6 DO Calcium=0,1;
7 INPUT Yield @;
8 OUTPUT;
9 END;
10 END;
11 END;
12 END;
13 DATALINES;
144.91 4.63 4.76 5.04 5.38 6.21 5.60 5.08
154.94 3.98 4.64 5.26 5.28 5.01 5.45 5.62
165.20 4.45 5.05 5.03 5.01 4.63 5.80 5.90
176.00 5.39 4.95 5.39 6.18 5.94 6.58 6.25
185.86 5.41 5.54 5.41 5.28 6.67 6.65 5.94
195.45 5.12 4.73 4.62 5.06 5.75 6.39 5.62
204.96 5.63 5.47 5.31 6.18 6.31 5.95 6.14
215.71 5.37 6.21 5.83 6.28 6.55 6.39 5.57
224.60 4.90 4.88 4.73 5.89 6.20 5.68 5.72
235.79 5.33 5.13 5.18 5.86 5.98 5.55 4.32
245.61 5.15 4.82 5.06 5.67 5.54 5.19 4.46
255.13 4.90 4.88 5.18 5.45 5.80 5.12 4.42
26;
2 Code Block
PROC ANOVA
Explanation :
This block executes a univariate analysis of variance using the PROC ANOVA procedure on the 'Barley' dataset. The `CLASS` statement identifies categorical variables (Rep, Soil, Calcium, Fertilizer). The `MODEL` statement specifies the linear model for the dependent variable 'Yield' as a function of main effects, interactions, and replication error terms, structured for a strip-split plot design. Several `TEST` statements perform specific hypothesis tests for the different effects (Fertilizer, Calcium, Soil, and their interactions) using the appropriate error terms for the factorial design. Finally, the `MEANS` statement calculates and displays the means for the specified factors and interactions (Fertilizer, Calcium, Soil, Calcium*Fertilizer).
Copied!
1PROC ANOVA DATA=Barley;
2 class Rep Soil Calcium Fertilizer;
3 model Yield =
4 Rep
5 Fertilizer Fertilizer*Rep
6 Calcium Calcium*Fertilizer Calcium*Rep(Fertilizer)
7 Soil Soil*Rep
8 Soil*Fertilizer Soil*Rep*Fertilizer
9 Soil*Calcium Soil*Fertilizer*Calcium
10 Soil*Calcium*Rep(Fertilizer);
11 test h=Fertilizer e=Fertilizer*Rep;
12 test h=Calcium calcium*fertilizer e=Calcium*Rep(Fertilizer);
13 test h=Soil e=Soil*Rep;
14 test h=Soil*Fertilizer e=Soil*Rep*Fertilizer;
15 test h=Soil*Calcium
16 Soil*Fertilizer*Calcium e=Soil*Calcium*Rep(Fertilizer);
17 means Fertilizer Calcium Soil Calcium*Fertilizer;
18RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : S A S S A M P L E L I B R A R Y NAME: ANOVAEX5 TITLE: Example 5 for PROC ANOVA PRODUCT: STAT SYSTEM: ALL KEYS: analysis of variance, balanced data, design PROCS: ANOVA DATA: REF: PROC ANOVA, EXAMPLE 5. MISC: