Published on :
Statistical CREATION_INTERNE

Analysis of an Unbalanced Two-Factor Design

This code is also available in: Deutsch Español Français
Awaiting validation
The script begins by setting the SAS© output title to 'Unbalanced Two-way Design'. It then creates a dataset named 'twoway' using a DATA step with integrated data via the DATALINES statement. This dataset contains the variables 'Treatment', 'Block', and 'y'. The PROC GLM procedure is then invoked on the 'twoway' dataset. It specifies 'Treatment' and 'Block' as classification variables ('CLASS') and fits a linear model for the dependent variable 'y' based on the main effects ('Treatment', 'Block') and their interaction ('Treatment | Block'). The 'means Treatment;' and 'lsmeans Treatment;' statements are used to calculate and display treatment means and adjusted least squares means. ODS (Output Delivery System) statements are used to specifically select the 'ModelANOVA' and 'Means' tables for output, and 'ods trace on;' activates ODS tracing to display information about available output tables.
Data Analysis

Type : CREATION_INTERNE


The 'twoway' dataset used for the analysis is created directly within the SAS script using the DATALINES statement. No external data source or SASHELP library is required for the creation of this dataset.

1 Code Block
DATA STEP Data
Explanation :
This DATA STEP block sets a title for the output and creates a dataset named 'twoway'. The data for this dataset is provided directly within the script via the DATALINES statement, which initializes the 'Treatment', 'Block', and 'y' variables with the specified values.
Copied!
1title 'Unbalanced Two-way Design';
2DATA twoway;
3 INPUT Treatment Block y ;
4 DATALINES;
51 1 17 1 1 28 1 1 19 1 1 21 1 1 19 1 2 43
61 2 30 1 2 39 1 2 44 1 2 44 1 3 16
72 1 21 2 1 21 2 1 24 2 1 25 2 2 39 2 2 45
82 2 42 2 2 47 2 3 19 2 3 22 2 3 16
93 1 22 3 1 30 3 1 33 3 1 31 3 2 46 3 3 26
103 3 31 3 3 26 3 3 33 3 3 29 3 3 25
11;
2 Code Block
PROC GLM
Explanation :
This block executes the GLM (General Linear Model) procedure on the 'twoway' dataset. It specifies 'Treatment' and 'Block' as classification variables and models 'y' based on these two factors and their interaction. It also requests the calculation and display of means and least squares means for the 'Treatment' variable. ODS statements are used to control the displayed output elements ('ModelANOVA' and 'Means') and to activate ODS tracing.
Copied!
1PROC GLM DATA=twoway;
2 class Treatment Block;
3 model y = Treatment | Block;
4 means Treatment;
5 lsmeans Treatment;
6 ods select ModelANOVA Means;
7 ods trace on;
8 ods show;
9RUN;
10 
11ods show;
12QUIT;
13ods show;
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