The script models data from a line-source sprinkler irrigation experiment published by Hanks et al. (1980). A first DATA STEP creates the 'line' dataset which contains yields (Y) for three crops (Cult), two blocks (Block), two directions (Dir) and six irrigation levels (Irrig). Then, the PROC MIXED procedure is used to fit a complex linear mixed model. The model specifies fixed effects (Crop, Direction, Irrigation and their interactions) and random effects (Block and its interactions with direction and irrigation). A Toeplitz covariance structure is defined for repeated measures. Finally, specific estimates are calculated to compare crops and evaluate irrigation-related trends.
Data Analysis
Type : CREATION_INTERNE
The data is created directly within the script via a DATA step and a 'datalines' statement. The 'line' dataset is generated in memory and does not depend on any external data source.
1 Code Block
DATA STEP Data
Explanation : This DATA STEP reads embedded data via 'datalines'. For each line, it reads a block identifier and a crop name. A 'do' loop then generates 12 observations (subplots), calculating the irrigation level (Irrig) and direction (Dir) based on the loop index. The yield variable (Y) is read for each subplot, and an observation is added to the 'line' table.
Explanation : This block applies the MIXED procedure to analyze the data. 'class' declares the categorical variables. 'model' defines the fixed effects model, including all interactions between Crop, Direction, and Irrigation. 'random' specifies the random effects. 'repeated' models the residual correlation with a Toeplitz structure for repeated measures. 'lsmeans' calculates least squares means and 'estimate' allows testing custom hypotheses on the model effects.
Copied!
proc mixed;
class Block Cult Dir Irrig;
model Y = Cult|Dir|Irrig;
random Block Block*Dir Block*Irrig;
repeated / type=toep(4) sub=Block*Cult r;
lsmeans Cult|Irrig;
estimate 'Bridger vs Luke' Cult 1 -1 0;
estimate 'Linear Irrig' Irrig -5 -3 -1 1 3 5;
estimate 'B vs L x Linear Irrig' Cult*Irrig
-5 -3 -1 1 3 5 5 3 1 -1 -3 -5;
run;
1
PROC MIXED;
2
class Block Cult Dir Irrig;
3
model Y = Cult|Dir|Irrig;
4
random Block Block*Dir Block*Irrig;
5
repeated / type=toep(4) sub=Block*Cult r;
6
lsmeans Cult|Irrig;
7
estimate 'Bridger vs Luke' Cult 1 -1 0;
8
estimate 'Linear Irrig' Irrig -5 -3 -1135;
9
estimate 'B vs L x Linear Irrig' Cult*Irrig
10
-5 -3 -1135531 -1 -3 -5;
11
RUN;
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.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.