Published on :
Statistics CREATION_INTERNE

Modeling diabetes patterns with PROC GAM

This code is also available in: Español Français
Awaiting validation
The script begins by creating a dataset named 'diabetes' via a DATA step. The data is provided directly in the code using 'datalines'. A new variable, 'logCP', is calculated by taking the natural logarithm of the 'CPeptide' variable. Then, the 'PROC GAM' procedure is used to fit a generalized additive model. This model aims to predict 'logCP' based on the non-linear effects of the 'Age' and 'BaseDeficit' variables, which are modeled using spline functions. The objective is to examine diabetes patterns, as indicated in the title.
Data Analysis

Type : CREATION_INTERNE


The data is created directly in the SAS script using a 'datalines' statement within the DATA step.

1 Code Block
DATA STEP Data
Explanation :
This DATA STEP block creates the 'diabetes' table. It reads three variables (Age, BaseDeficit, CPeptide) from embedded data ('datalines'), then calculates a fourth variable 'logCP' as the natural logarithm of 'CPeptide'. The '@@' option allows reading multiple observations from the same data line.
Copied!
1title 'Patterns of Diabetes';
2DATA diabetes;
3 INPUT Age BaseDeficit CPeptide @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json;
4 logCP = log(CPeptide);
5 DATALINES;
65.2 -8.1 4.8 8.8 -16.1 4.1 10.5 -0.9 5.2
710.6 -7.8 5.5 10.4 -29.0 5.0 1.8 -19.2 3.4
812.7 -18.9 3.4 15.6 -10.6 4.9 5.8 -2.8 5.6
91.9 -25.0 3.7 2.2 -3.1 3.9 4.8 -7.8 4.5
107.9 -13.9 4.8 5.2 -4.5 4.9 0.9 -11.6 3.0
1111.8 -2.1 4.6 7.9 -2.0 4.8 11.5 -9.0 5.5
1210.6 -11.2 4.5 8.5 -0.2 5.3 11.1 -6.1 4.7
1312.8 -1.0 6.6 11.3 -3.6 5.1 1.0 -8.2 3.9
1414.5 -0.5 5.7 11.9 -2.0 5.1 8.1 -1.6 5.2
1513.8 -11.9 3.7 15.5 -0.7 4.9 9.8 -1.2 4.8
1611.0 -14.3 4.4 12.4 -0.8 5.2 11.1 -16.8 5.1
175.1 -5.1 4.6 4.8 -9.5 3.9 4.2 -17.0 5.1
186.9 -3.3 5.1 13.2 -0.7 6.0 9.9 -3.3 4.9
1912.5 -13.6 4.1 13.2 -1.9 4.6 8.9 -10.0 4.9
2010.8 -13.5 5.1
21;
2 Code Block
PROC GAM
Explanation :
This block uses the GAM (Generalized Additive Model) procedure to model the 'logCP' variable based on 'Age' and 'BaseDeficit'. The 'model' statement specifies that both independent variables are fitted using spline functions, allowing for the capture of non-linear relationships. The 'ods graphics on;' statement enables the creation of graphs to visualize the results.
Copied!
1ods graphics on;
2PROC GAM DATA=diabetes;
3 model logCP = spline(Age) spline(BaseDeficit);
4RUN;
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: gamgs, TITLE: Getting Started Example for PROC GAM, DESC: Patterns of Diabetes, REF: Sockett et al. 1987, PRODUCT: STAT