Published on :
Statistique CREATION_INTERNE

ANOVA Analysis for Sugar Beet

This code is also available in: Deutsch Español Français
Awaiting validation
The objective of this script is to analyze the effects of different factors on the yield (Y) of sugar beets. The data is structured according to a latin square split-plot design, with factors 'Harvest', 'Rep' (repetition), 'Column', and 'Variety'. The DATA STEP block generates observations from 'datalines' to construct the 'Beets' dataset. Then, PROC ANOVA is used to model the yield based on these factors and to perform specific tests on the effects of the factors Harvest, Rep, Column, and Variety, using appropriate error terms for the experimental design.
Data Analysis

Type : CREATION_INTERNE


The data for the 'Beets' dataset is directly created and populated within the SAS script via a DATALINES block. It represents the results of an experiment with a latin square split-plot design, measuring the yield of different sugar beet varieties over two harvests.

1 Code Block
DATA STEP Data
Explanation :
This DATA STEP block is responsible for creating the 'Beets' dataset. It uses nested 'do' loops to generate the variables 'Harvest' (1 to 2), 'Rep' (1 to 6), and 'Column' (1 to 6). The 'Variety' variable and the dependent variable 'Y' (yield) are read sequentially from the DATALINES block. The ' @code_sas/16.4'.sas instruction at the end of 'input' keeps the pointer on the same data line until all observations for a combination of Harvest, Rep, and Column are read, which is typical for experimental designs where multiple measurements are on the same physical data line. The 'title1' and 'title3' statements define the SAS output titles.
Copied!
1title1 'Sugar Beet Varieties';
2title3 'Latin Square Split-Plot Design';
3DATA Beets;
4 DO Harvest=1 to 2;
5 DO Rep=1 to 6;
6 DO Column=1 to 6;
7 INPUT Variety Y @;
8 OUTPUT;
9 END;
10 END;
11 END;
12 DATALINES;
133 19.1 6 18.3 5 19.6 1 18.6 2 18.2 4 18.5
146 18.1 2 19.5 4 17.6 3 18.7 1 18.7 5 19.9
151 18.1 5 20.2 6 18.5 4 20.1 3 18.6 2 19.2
162 19.1 3 18.8 1 18.7 5 20.2 4 18.6 6 18.5
174 17.5 1 18.1 2 18.7 6 18.2 5 20.4 3 18.5
185 17.7 4 17.8 3 17.4 2 17.0 6 17.6 1 17.6
193 16.2 6 17.0 5 18.1 1 16.6 2 17.7 4 16.3
206 16.0 2 15.3 4 16.0 3 17.1 1 16.5 5 17.6
211 16.5 5 18.1 6 16.7 4 16.2 3 16.7 2 17.3
222 17.5 3 16.0 1 16.4 5 18.0 4 16.6 6 16.1
234 15.7 1 16.1 2 16.7 6 16.3 5 17.8 3 16.2
245 18.3 4 16.6 3 16.4 2 17.6 6 17.1 1 16.5
25;
2 Code Block
PROC ANOVA
Explanation :
This block uses the PROC ANOVA procedure to perform the analysis of variance on the 'Beets' dataset. The 'class' statement declares the categorical variables (factors) 'Column', 'Rep', 'Variety', and 'Harvest'. The 'model' statement specifies the linear model, where 'Y' is the dependent variable and the other variables are the factors and their interactions. The 'test' statements are used to specify the appropriate error terms for hypothesis testing. For example, 'test h=Rep Column Variety e=Rep*Column*Variety' indicates that the effect of 'Rep', 'Column', and 'Variety' should be tested against the 'Rep*Column*Variety' error, which is common in split-plot and latin square designs for whole-plot effects. Similarly, 'test h=Harvest e=Harvest*Rep' tests the effect of 'Harvest' against its interaction with 'Rep'.
Copied!
1PROC ANOVA DATA=Beets;
2 class Column Rep Variety Harvest;
3 model Y=Rep Column Variety Rep*Column*Variety
4 Harvest Harvest*Rep
5 Harvest*Variety;
6 test h=Rep Column Variety e=Rep*Column*Variety;
7 test h=Harvest e=Harvest*Rep;
8RUN;
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