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!
data Shoulder_tip_pain;
input trt $ gender $ age t1-t6;
subject_id = _n_;
array tt t1-t6;
do over tt;
y = tt;
time = _i_;
output;
end;
datalines;
y f 64 1 1 1 1 1 1
y m 41 3 2 1 1 1 1
y f 77 3 2 2 2 1 1
y f 54 1 1 1 1 1 1
y f 66 1 1 1 1 1 1
y m 56 1 2 1 1 1 1
y m 81 1 3 2 1 1 1
y f 24 2 2 1 1 1 1
y f 56 1 1 1 1 1 1
y f 29 3 1 1 1 1 1
y m 65 1 1 1 1 1 1
y f 68 2 1 1 1 1 2
y m 77 1 2 2 2 2 2
y m 35 3 1 1 1 3 3
y m 66 2 1 1 1 1 1
y f 70 1 1 1 1 1 1
y m 79 1 1 1 1 1 1
y f 65 2 1 1 1 1 1
y f 61 4 4 2 4 2 2
y f 67 4 4 4 2 1 1
y f 32 1 1 1 2 1 1
y f 33 1 1 1 2 1 2
n f 20 5 2 3 5 5 4
n f 50 1 5 3 4 5 3
n f 40 4 4 4 4 1 1
n m 54 4 4 4 4 4 3
n m 34 2 3 4 3 3 2
n f 34 3 4 3 3 3 2
n m 56 3 3 4 4 4 3
n f 82 1 1 1 1 1 1
n m 56 1 1 1 1 1 1
n m 52 1 5 5 5 4 3
n f 65 1 3 2 2 1 1
n f 53 2 2 3 4 2 2
n f 40 2 2 1 3 3 2
n f 58 1 1 1 1 1 1
n m 63 1 1 1 1 1 1
n f 41 5 5 5 4 3 3
n m 72 3 3 3 3 1 1
n f 60 5 4 4 4 2 2
n m 61 1 3 3 3 2 1
;
1
DATA 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;
11
y f 64111111
12
y m 41321111
13
y f 77322211
14
y f 54111111
15
y f 66111111
16
y m 56121111
17
y m 81132111
18
y f 24221111
19
y f 56111111
20
y f 29311111
21
y m 65111111
22
y f 68211112
23
y m 77122222
24
y m 35311133
25
y m 66211111
26
y f 70111111
27
y m 79111111
28
y f 65211111
29
y f 61442422
30
y f 67444211
31
y f 32111211
32
y f 33111212
33
n f 20523554
34
n f 50153453
35
n f 40444411
36
n m 54444443
37
n m 34234332
38
n f 34343332
39
n m 56334443
40
n f 82111111
41
n m 56111111
42
n m 52155543
43
n f 65132211
44
n f 53223422
45
n f 40221332
46
n f 58111111
47
n m 63111111
48
n f 41555433
49
n m 72333311
50
n f 60544422
51
n m 61133321
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!
proc format;
value $abc 'y' = 'Active'
'n' = 'Placebo';
value $xyz 'f' = 'Female'
'm' = 'Male';
run;
1
PROC FORMAT;
2
value $abc 'y' = 'Active'
3
'n' = 'Placebo';
4
value $xyz 'f' = 'Female'
5
'm' = 'Male';
6
RUN;
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!
ods html;
proc surveylogistic data=Shoulder_tip_pain;
class trt gender;
model y = trt gender age time / link=clogit ;
cluster subject_id;
format trt $abc. gender $xyz. ;
title1 '*** Results from fitting a GEE Cumulative Logit Model ***';
title2 '*** to the Shoulder Tip Pain Data in Lumley (1996) ***';
run;
ods html close;
1
ods html;
2
PROC SURVEYLOGISTICDATA=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) ***';
9
RUN;
10
ods 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!
proc genmod data=Shoulder_tip_pain;
class subject_id trt gender;
model y = trt gender age time / dist=mult link=clogit type3;
repeated subject=subject_id / type=ind;
format trt $abc. gender $xyz. ;
title3 '*** Results using PROC GENMOD ***';
run;
1
PROC GENMODDATA=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 ***';
7
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.
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.