Published on :
Statistical INTERNAL_CREATION

GEE Analysis of Ordinal Shoulder Pain Data

This code is also available in: Deutsch Español Français
Awaiting validation
The script begins by creating a SAS© dataset from raw data directly included in the code. This data, initially in wide format, is restructured into long format to facilitate the analysis of repeated measures over time. Subsequently, two statistical procedures, PROC SURVEYLOGISTIC and PROC GENMOD, are used to fit cumulative logit models. This approach allows modeling the ordinal response variable (pain level) while accounting for the correlation between observations from the same subject at different time points.
Data Analysis

Type : INTERNAL_CREATION


Data is entirely generated within the script. A DATA step reads observations via a 'datalines' instruction and transforms them from a wide format (one row per subject) to a long format (one row per subject per measurement point).

1 Code Block
DATA STEP Data
Explanation :
This DATA STEP block creates the 'Shoulder_tip_pain' table. It reads embedded data via 'datalines', assigns a unique 'subject_id' to each patient, then uses a loop to transform the 6 pain measurements (t1-t6) from a wide format to a long format, with one row per time point ('time').
Copied!
1DATA Shoulder_tip_pain;
2 INPUT trt $ gender $ age t1-t6;
3 subject_id = _n_;
4 array tt t1-t6;
5 DO over tt;
6 y = tt;
7 time = _i_;
8 OUTPUT;
9 END;
10 DATALINES;
11y f 64 1 1 1 1 1 1
12y m 41 3 2 1 1 1 1
13y f 77 3 2 2 2 1 1
14y f 54 1 1 1 1 1 1
15y f 66 1 1 1 1 1 1
16y m 56 1 2 1 1 1 1
17y m 81 1 3 2 1 1 1
18y f 24 2 2 1 1 1 1
19y f 56 1 1 1 1 1 1
20y f 29 3 1 1 1 1 1
21y m 65 1 1 1 1 1 1
22y f 68 2 1 1 1 1 2
23y m 77 1 2 2 2 2 2
24y m 35 3 1 1 1 3 3
25y m 66 2 1 1 1 1 1
26y f 70 1 1 1 1 1 1
27y m 79 1 1 1 1 1 1
28y f 65 2 1 1 1 1 1
29y f 61 4 4 2 4 2 2
30y f 67 4 4 4 2 1 1
31y f 32 1 1 1 2 1 1
32y f 33 1 1 1 2 1 2
33n f 20 5 2 3 5 5 4
34n f 50 1 5 3 4 5 3
35n f 40 4 4 4 4 1 1
36n m 54 4 4 4 4 4 3
37n m 34 2 3 4 3 3 2
38n f 34 3 4 3 3 3 2
39n m 56 3 3 4 4 4 3
40n f 82 1 1 1 1 1 1
41n m 56 1 1 1 1 1 1
42n m 52 1 5 5 5 4 3
43n f 65 1 3 2 2 1 1
44n f 53 2 2 3 4 2 2
45n f 40 2 2 1 3 3 2
46n f 58 1 1 1 1 1 1
47n m 63 1 1 1 1 1 1
48n f 41 5 5 5 4 3 3
49n m 72 3 3 3 3 1 1
50n f 60 5 4 4 4 2 2
51n m 61 1 3 3 3 2 1
52;
2 Code Block
PROC FORMAT
Explanation :
This procedure defines two custom formats. The '$abc' format is applied to the 'trt' variable to label treatment groups ('Active', 'Placebo'), and the '$xyz' format is applied to 'gender' to label sex ('Female', 'Male').
Copied!
1PROC FORMAT;
2 value $abc 'y' = 'Active'
3 'n' = 'Placebo';
4 value $xyz 'f' = 'Female'
5 'm' = 'Male';
6RUN;
3 Code Block
PROC SURVEYLOGISTIC
Explanation :
This block uses PROC SURVEYLOGISTIC to fit a GEE model with a cumulative logit link. The 'cluster subject_id' statement specifies that observations are correlated within each subject. The model evaluates the effect of treatment, gender, age, and time on the ordinal response 'y'.
Copied!
1ods html;
2PROC SURVEYLOGISTIC DATA=Shoulder_tip_pain;
3 class trt gender;
4 model y = trt gender age time / link=clogit ;
5 cluster subject_id;
6 FORMAT trt $abc. gender $xyz. ;
7 title1 '*** Results from fitting a GEE Cumulative Logit Model ***';
8 title2 '*** to the Shoulder Tip Pain Data in Lumley (1996) ***';
9RUN;
10ods html close;
4 Code Block
PROC GENMOD
Explanation :
This block uses PROC GENMOD to perform an alternative or confirmatory GEE analysis. It specifies a multinomial distribution with a cumulative logit link. The 'repeated' statement declares the nature of repeated measures per subject, with an independent working correlation structure ('type=ind').
Copied!
1PROC GENMOD DATA=Shoulder_tip_pain;
2 class subject_id trt gender;
3 model y = trt gender age time / dist=mult link=clogit type3;
4 repeated subject=subject_id / type=ind;
5 FORMAT trt $abc. gender $xyz. ;
6 title3 '*** Results using PROC GENMOD ***';
7RUN;
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.