Example 1 for PROC GENMOD

This code is also available in: Deutsch Español Français English
Difficulty Level
Beginner
Published on :
The script begins by creating a dataset named 'drug' using a DATA statement and in-line data (datalines). This dataset contains information on different substances ('drug'), a continuous variable 'x', the number of successes 'r' and the total number of trials 'n'. Then, it uses PROC GENMOD to fit a logistic regression model. The 'drug' variable is declared as a classification variable (CLASS). The model specifies that 'r' events out of 'n' trials are modeled as a function of 'x' and 'drug', using a binomial distribution (dist=bin) and a logit link function (link=logit). The 'lrci' option requests the calculation of likelihood ratio confidence intervals.
Data Analysis

Type : CREATION_INTERNE


The 'drug' dataset is created directly in the script via the DATA statement and in-line data (datalines).

1 Code Block
DATA STEP Data
Explanation :
This code block uses a DATA step to create the 'drug' dataset by reading data directly included in the script via the DATALINES statement. The variables created are 'drug' (character), 'x', 'r', and 'n' (numeric).
Copied!
1DATA drug;
2 INPUT drug$ x r n;
3 DATALINES;
4A .1 1 10 A .23 2 12 A .67 1 9
5B .2 3 13 B .3 4 15 B .45 5 16 B .78 5 13
6C .04 0 10 C .15 0 11 C .56 1 12 C .7 2 12
7D .34 5 10 D .6 5 9 D .7 8 10
8E .2 12 20 E .34 15 20 E .56 13 15 E .8 17 20
9;
2 Code Block
PROC GENMOD
Explanation :
This block executes the GENMOD procedure to fit a generalized linear model. It specifies the 'drug' dataset as input, declares 'drug' as a classification variable, and defines a logistic regression model ('dist=bin', 'link=logit') where the ratio 'r/n' is modeled as a function of 'x' and 'drug'. The 'lrci' option requests likelihood ratio-based confidence intervals.
Copied!
1PROC GENMOD DATA=drug;
2 class drug;
3 model r/n = x drug / dist = bin
4 link = logit
5 lrci;
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 : 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.