BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
EMCCMDoc
Calcite | Level 5

Hi All,

 

New to the forum.  Hope this is the appropriate place/means to ask this question.  I'm relatively new to SAS and have hit a wall trying to figure out an analysis.  I have a large dataset, but for the purposes of this question, its fairly straightforward.  I have four repeated measurements on the same patient at the same time with different devices.  Think, measuring someone's weight on 4 different scales.  Each of the four weights is in its own column.  I'm trying to perform an anova to compare the groups, but I haven't been able to get the syntax right.

 

Any help would be appreciated.

 

Example of data for explanation purposes:

 

Patient Number                   Scale 1      Scale 2    Scale 3      Scale 4

1                                           100            105         103            98

2                                           105            105          107         115

3                                             83              82            83          87

....

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
You would need to transpose your data, via PROC TRANSPOSE and then use PROC ANOVA on it.

proc transpose data=have out=long;
by patient_number;
var scale1-scale4;
run;

proc anova data=long;
class _name_;
model Col1 = _name_;
run;

View solution in original post

6 REPLIES 6
Reeza
Super User
You would need to transpose your data, via PROC TRANSPOSE and then use PROC ANOVA on it.

proc transpose data=have out=long;
by patient_number;
var scale1-scale4;
run;

proc anova data=long;
class _name_;
model Col1 = _name_;
run;
PaigeMiller
Diamond | Level 26

When you do an ANOVA, you need to decide on a model to fit, and you haven't specifically told us what model you want to fit. So, we should not have to read between the lines and guess, as I am about to do, and maybe guess wrong, but really @EMCCMDoc, tell us what model you want to fit. (And by the way, your statement that it is like repeated measures with 4 different scales doesn't mean anything here, you can't have repeated measures with different scales, and so I am guessing you didn't really mean you want a repeated measures analysis, and neither I nor Reeza have provided code for a repeated measures analysis).

 

So, I'm guessing you want the equivalent of a paired T-test, but with 4 groups instead of the two that are normally in a paired t-test. Thus:

 

data have;
input PatientNumber Scale1 Scale2 Scale3 Scale4;
cards;
1  100            105         103            98
2  105            105          107         115
3   83             82            83          87
;
proc transpose data=have out=long;
by patientnumber;
var scale1-scale4;
run;

proc glm data=long;
	class patientnumber _name_;
	model col1=patientnumber _name_;
run;

And don't use PROC ANOVA here unless your entire data set has no missing values.

 

 

--
Paige Miller
PaigeMiller
Diamond | Level 26

@EMCCMDoc 

I see you have marked another answer as incorrect, and I respectfully disagree.

 

Your experimental design is EITHER a repeated measures (although I explained why it probably is not, or your explanation is flawed), or  it is the ANOVA equivalent of a paired t-test with 4 groups, and the the answer marked correct is not the right analysis for either of those designs.

--
Paige Miller
Reeza
Super User

I concur with @PaigeMiller by the way, if your experimental design is repeated measures across the same individual my solution isn't correct. I answer the question asked, but this isn't the correct analysis for your experimental design, which I did not factor in.

EMCCMDoc
Calcite | Level 5
I should clarify. I am using the term weight and scale, but I now realize this is a relatively poor analogy. What I mean are actually weight (like body mass) and a scale as in a measuring scale like you use in the bathroom. Imagine if you lined people up and measured how heavy they were using four different tools. I selected that answer as correct because, when transposed, SAS was able to solve. Whether or not that’s statistically appropriate, feel free to comment.

Yes, I’m looking for the equivalent of a paired t-test, but for four groups. I was under the impression that an anova was the appropriate test. I’m not looking to model the relationship between the four groups, simply evaluate whether or not the scales measure the weights the same.

As far as missing data, there are two missing data points for one of the four scales, but the other three are complete.

Regards.
PaigeMiller
Diamond | Level 26

Whether or not that’s statistically appropriate, feel free to comment.

Already commented. It's not appropriate.

 

I’m looking for the equivalent of a paired t-test, but for four groups. I was under the impression that an anova was the appropriate test.

A plain old ANOVA, like the one you marked correct, is the equivalent of an un-paired t-test. The code I provided is the ANOVA version of a paired t-test.

 

As far as missing data, there are two missing data points for one of the four scales, but the other three are complete.

 

Do not use PROC ANOVA, use PROC GLM.

--
Paige Miller

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1371 views
  • 2 likes
  • 3 in conversation