- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi SAS Community,
How do I get SAS to output mean of means as a dataset, without doing two proc means statements? I want calculate means between two study, but I want use the subject means to calculate this first. Currently I am doing by two proc means statements but is this long way the only way to do.
Any help would be brilliant
proc sort data=ffgorn_v6; by study subject; run; proc means data=ffgorn_v6 nway; class study subject; var abs diff ffhang; output out=means_1 Mean= /autoname; run;
proc means data=means_1;
by study;
var abs_Mean diff_Mean ffhang_Mean;
output out=means_2 Mean= /autoname;
run;
Thank you!! 💖
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
UNTESTED, as I don't have your data
proc glm data=ffgorn_v6;
class subject study;
model abs diff ffhang = study subject(study);
lsmeans study;
run;
quit;
The LSMEANS for study are I think what you want here.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
UNTESTED, as I don't have your data
proc glm data=ffgorn_v6;
class subject study;
model abs diff ffhang = study subject(study);
lsmeans study;
run;
quit;
The LSMEANS for study are I think what you want here.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Paige. What does "subject(study)" do? I actually have another variable now that I want to add (sex). Should I therefore add the below?
model abs = study subject(study) sex(study)
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Explain, in terms of your original problem, where sex impacts the analysis.
Unless I am very wrong, the sex of a subject is uniquely determined by the subject; there can't be a situation where a subject has two different sexes, so I don't see why adding in sex is relevant here.
subject(study)
indicates that subject is nested within study (rather than subjects being part of multiple studies)
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hahaha, yes it is not really that variable, I tried to simplify the problem but it backfired... apologies!
It is instead "condition" which is a categorical variable taking on 11 different values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This is not an explanation. This is simply changing the problem without an explanation.
So start over. Pretend this entire conversation has not happened. Do not refer to anything that has already been stated. From the beginning, describe the problem involving subject study and condition.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
OK, so the problem is as I described in another post. I have:
data in;
input study $ subject device $ Yes_No Measure;
datalines;
A 1 a 1 348
A 1 a 0 1073
A 1 a 1 404
A 1 a 1 685
A 1 b 1 369
A 1 b 0 278
A 1 b 0 145
A 1 b 0 181
A 1 b 1 168
A 2 c 1 143
A 2 c 1 212
A 2 c 0 851
A 2 c 1 214
A 2 c 1 299
A 2 c 0 1201
A 2 d 0 406
A 2 d 0 124
A 2 d 1 953
A 2 d 0 169
A 2 d 0 783
A 3 e 1 153
A 3 e 1 151
A 3 e 0 217
A 3 e 0 313
A 3 e 0 864
A 4 f 1 5058
A 4 f 1 166
A 4 f 0 145
A 4 f 1 230
B 4 f 1 94
B 4 f 1 116
B 4 f 0 139
B 4 f 1 517
B 4 f 1 600
B 4 f 0 147
B 5 g 0 91
B 5 g 0 136
B 5 g 1 185
B 5 g 0 210
B 5 g 0 152
B 6 h 1 137
B 6 h 1 783
B 6 h 0 265
B 6 h 0 102
B 6 i 0 128
B 6 i 1 216
B 6 i 1 670
B 6 i 0 132
;
run;
and I want to work out the difference in "Measure" across study.
So device is nested within subject, and subject is nested in study.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc glm data=in;
class study subject device;
model measure = study subject(study) device(subject*study);
lsmeans study subject(study) device(subject*study);
quit;
The LSMEANS are what you want.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Consider using the FEATURE of Proc Means /Summary of doing multiple types of summaries at one time. Remove the NWAY and you will have summaries of 1) the data overall, 2) study, 3) subject and 4)study with subject. The _TYPE_ variable can be used to select the desired one (look at your output set).
proc means data=ffgorn_v6nway; class study subject; var abs diff ffhang; output out=means_1 Mean= /autoname; run;