Published on :
Statistical CREATION_INTERNE

Example 4 for PROC CATMOD: Log-Linear Model

This code is also available in: Deutsch Español Français
Awaiting validation
This SAS© script implements a log-linear model to analyze Bartlett's data, which examines the survival status (dead or alive) of cuttings of different lengths, planted at two distinct times. The model explores the interactions between cutting length, planting time, and survival status, excluding the three-variable interaction. The CATMOD procedure is used for this analysis.
Data Analysis

Type : CREATION_INTERNE


Bartlett's data is created directly in the script via a DATALINES block. The variables are 'Length' (long/short), 'Time' (spring/immediately), 'Status' (dead/alive) and 'wt' (weight/frequency).

1 Code Block
DATA STEP Data
Explanation :
This DATA Step block creates the 'bartlett' dataset from internal data provided via the DATALINES statement. It defines the variables Length, Time, Status, and wt, representing respectively the cutting length, planting time, survival status, and the weight or frequency of each factor combination. The invalid part of the INPUT line (` @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json`) has been removed to make the code executable.
Copied!
1DATA bartlett;
2 INPUT LENGTH Time STATUS wt;
3 DATALINES;
41 1 1 156
51 1 2 84
61 2 1 84
71 2 2 156
82 1 1 107
92 1 2 133
102 2 1 31
112 2 2 209
12;
13 
2 Code Block
PROC CATMOD
Explanation :
This block uses PROC CATMOD to fit a log-linear model to Bartlett's data. The `weight wt` option indicates that the 'wt' variable contains the observation frequencies. The `model` statement specifies the model variables and `_response_` indicates that the model applies to the implicit response variable. The `noparm` and `pred=freq` options are used for output. The `loglin` statement fits a log-linear model without a third-order interaction (specified by ` @ 2`), exploring interactions up to order 2 between Length, Time, and Status.
Copied!
1title 'Bartlett''s Data';
2PROC CATMOD DATA=bartlett;
3 weight wt;
4 model LENGTH*Time*STATUS=_response_
5 / noparm pred=freq;
6 loglin LENGTH|Time|STATUS @ 2;
7 title2 'Model with No 3-Variable Interaction';
8QUIT;
9 
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