Published on :
Statistics CREATION_INTERNE

Exact Poisson Regression with PROC GENMOD

This code is also available in: Deutsch Español Français
Awaiting validation
The script begins by creating a dataset named 'ingots' which contains the number of defective ingots ('Notready') for different combinations of heating time ('Heat') and soaking time ('Soak'), as well as the total tested ('Total'). It then calculates the logarithm of the total ('lnTotal') to use as an offset variable in the model. The PROC GENMOD procedure is then called to fit a Poisson regression model, where 'Notready' is the dependent variable. An exact conditional analysis is requested for the 'Heat' and 'Soak' parameters to obtain more precise estimates and tests, which is particularly useful with small samples.
Data Analysis

Type : CREATION_INTERNE


Data is created directly in the script using a DATA step and the 'datalines' statement.

1 Code Block
DATA STEP Data
Explanation :
This data block creates the 'ingots' table. It reads the 'Heat', 'Soak', 'Notready', and 'Total' variables from the in-line data (datalines), then calculates a new 'lnTotal' variable which is the logarithm of 'Total'. This table is the source for statistical analysis.
Copied!
1DATA ingots;
2 INPUT Heat Soak Notready Total @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json;
3 lnTotal= log(Total);
4 DATALINES;
57 1.0 0 10 14 1.0 0 31 27 1.0 1 56 51 1.0 3 13
67 1.7 0 17 14 1.7 0 43 27 1.7 4 44 51 1.7 0 1
77 2.2 0 7 14 2.2 2 33 27 2.2 0 21 51 2.2 0 1
87 2.8 0 12 14 2.8 0 31 27 2.8 1 22 51 4.0 0 1
97 4.0 0 9 14 4.0 0 19 27 4.0 1 16
10;
11 
2 Code Block
PROC GENMOD
Explanation :
This block uses PROC GENMOD to perform Poisson regression. 'Heat' and 'Soak' are defined as class variables. The model predicts 'Notready' based on 'Heat' and 'Soak', with 'lnTotal' as an offset variable to normalize exposure. The 'exact' statement requests an exact conditional analysis for the 'Heat' and 'Soak' variables, and 'exactoptions' sets a time limit for the status of this analysis.
Copied!
1PROC GENMOD DATA=ingots;
2 class Heat Soak / param=ref;
3 model Notready=Heat Soak / offset=lnTotal dist=Poisson link=log;
4 exact Heat Soak / joint estimate;
5 exactoptions statustime=10;
6RUN;
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 : SAS SAMPLE LIBRARY, NAME: GENMEX11, TITLE: Example 11 for PROC GENMOD, PRODUCT: STAT