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!
data insure;
input n c car$ age;
ln = log(n);
datalines;
500 42 small 1
1200 37 medium 1
100 1 large 1
400 101 small 2
500 73 medium 2
300 14 large 2
;
1
DATA insure;
2
INPUT n c car$ age;
3
ln = log(n);
4
DATALINES;
5
50042 small 1
6
120037 medium 1
7
1001 large 1
8
400101 small 2
9
50073 medium 2
10
30014 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!
proc genmod data=insure;
class car age;
model c = car age / dist = poisson
link = log
offset = ln;
run;
1
PROC GENMODDATA=insure;
2
class car age;
3
model c = car age / dist = poisson
4
link = log
5
offset = ln;
6
RUN;
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!
proc genmod data=insure;
class car age;
model c = car age / dist = poisson
link = log
offset = ln
type1
type3;
run;
1
PROC GENMODDATA=insure;
2
class car age;
3
model c = car age / dist = poisson
4
link = log
5
offset = ln
6
type1
7
type3;
8
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.
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.
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.