PROC GENMOD Introduction Example

This code is also available in: Deutsch Español Français
Difficulty Level
Beginner
Published on :
The script begins by creating a dataset named 'insure' containing information on the number of policies (n), the number of claims (c), car type (car), and age (age). A variable 'ln' is calculated as the natural logarithm of 'n', intended for use as an offset in the model. Two PROC GENMOD calls are made: the first fits a Poisson model with a log link and offset, while the second adds TYPE1 and TYPE3 options for effect tests.
Data Analysis

Type : CREATION_INTERNE


The 'insure' dataset is created directly within the script via a DATA STEP and 'datalines' statements, meaning all data is generated internally without external dependencies or the use of default SAS libraries like SASHELP.

1 Code Block
DATA STEP Data
Explanation :
This DATA STEP block creates the 'insure' dataset. It reads variables 'n', 'c', 'car' (character), and 'age' from the provided data lines. The 'ln' variable is then calculated as the natural logarithm of 'n', which will serve as an offset in the PROC GENMOD analyses to account for exposure.
Copied!
1DATA insure;
2 INPUT n c car$ age;
3 ln = log(n);
4 DATALINES;
5500 42 small 1
61200 37 medium 1
7100 1 large 1
8400 101 small 2
9500 73 medium 2
10300 14 large 2
11;
2 Code Block
PROC GENMOD
Explanation :
This first PROC GENMOD call fits a generalized linear model. The 'car' and 'age' variables are declared as classification ('class') variables. The model specifies 'c' (number of claims) as the dependent variable, modeled by 'car' and 'age'. The distribution is set to 'poisson', the link function to 'log', and 'ln' is used as an 'offset' to adjust the model based on exposure (log(n)).
Copied!
1PROC GENMOD DATA=insure;
2 class car age;
3 model c = car age / dist = poisson
4 link = log
5 offset = ln;
6RUN;
3 Code Block
PROC GENMOD
Explanation :
This second PROC GENMOD call is similar to the first but includes 'type1' and 'type3' options in the 'model' statement. These options request Type 1 (sequential) and Type 3 (marginal) effect tests to evaluate the significance of the 'car' and 'age' variables in the Poisson model. These tests provide additional information on the contribution of each factor.
Copied!
1PROC GENMOD DATA=insure;
2 class car age;
3 model c = car age / dist = poisson
4 link = log
5 offset = ln
6 type1
7 type3;
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


Related Documentation

Aucune documentation spécifique pour cette catégorie.