Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Comparing means between several groups

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 03-29-2017 08:40 AM
(18368 views)

Hello,

I asking for your help.

I have 3 variables that divided to 4 groups (Quantitative variables).

I intend to check if there is any difference between the groups for each variable.

My difficulty in using ANOVA - it indicates that one of the group is different but it does not indicate which one of the group is different.

Can you please advise what king of test to use in order to get indication which group is different in relate to the other. Should I use TTEST in the following way: checking one group in relate to the other 3 groups together (=as another one group)?

I hope my question is clear...

Thanks a lot!

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

One way to group values for analysis is to use a custom format. This has an advantage that you do not need to add variables.

Then use the CLASS statement to indicate the variable used to define the classification groups for the test.

proc format library=work; value firstgroup 1 = '1' 2,3,4 = '2-4'; value secgroup 2='2' 1,3,4 = '1,3,4'; run; proc ttest data=sasuser.sasfile010916; class stage; format state firstgroup.; var ROA1 ROA2 ROA3 ROA4 ROE1 ROE2 ROIC Q LNQ ; run; proc ttest data=sasuser.sasfile010916; class stage; format state secgroup.; var ROA1 ROA2 ROA3 ROA4 ROE1 ROE2 ROIC Q LNQ ; run;

15 REPLIES 15

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Use the MEANS statement in PROC ANOVA or PROC GLM.

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@PaigeMiller - thanks for your answer!

But if I want to test it with proc ttest, I want to compare between **1 group** in relate to **ALL 3 OTHER GROUPS TOGETHER**. So, what is wrong with my following code:

proc ttest data=sasuser.sasfile010916;

where stage=1;

var ROA1 ROA2 ROA3 ROA4 ROE1 ROE2 ROIC Q LNQ ;

run;

Remarks - the groups are in variable STAGE that has the values - 1,2,3,4. How can I relate to groups 2-4 together (as 1 group)?

Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

You want to use the CONTRAST statement in PROC GLM (not PROC ANOVA).

If you scroll down to the last example in the CONTRAST statement documentation, it shows how you would compare a control group to the average of the others, which if I am understanding you properly is what you are trying to do.

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

One way to group values for analysis is to use a custom format. This has an advantage that you do not need to add variables.

Then use the CLASS statement to indicate the variable used to define the classification groups for the test.

proc format library=work; value firstgroup 1 = '1' 2,3,4 = '2-4'; value secgroup 2='2' 1,3,4 = '1,3,4'; run; proc ttest data=sasuser.sasfile010916; class stage; format state firstgroup.; var ROA1 ROA2 ROA3 ROA4 ROE1 ROE2 ROIC Q LNQ ; run; proc ttest data=sasuser.sasfile010916; class stage; format state secgroup.; var ROA1 ROA2 ROA3 ROA4 ROE1 ROE2 ROIC Q LNQ ; run;

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

**format stage firstgroup** and not** format state firstgroup**, right?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@ballardw wrote:

One way to group values for analysis is to use a custom format. This has an advantage that you do not need to add variables.

Then use the CLASS statement to indicate the variable used to define the classification groups for the test.

proc format library=work; value firstgroup 1 = '1' 2,3,4 = '2-4'; value secgroup 2='2' 1,3,4 = '1,3,4'; run; proc ttest data=sasuser.sasfile010916; class stage; format state firstgroup.; var ROA1 ROA2 ROA3 ROA4 ROE1 ROE2 ROIC Q LNQ ; run; proc ttest data=sasuser.sasfile010916; class stage; format state secgroup.; var ROA1 ROA2 ROA3 ROA4 ROE1 ROE2 ROIC Q LNQ ; run;

Hello, @ballardw, it seems to me that this doesn't give the same answer as a CONTRAST statement in a PROC GLM analysis, because this PROC TTEST would use a different error term. In my understanding of the matter, I think the proper error term would indeed be the analysis-of-variance (PROC GLM) error term, and not the error derived via this PROC TTEST, specifically because the PROC GLM analysis-of-variance method would account for the group-to-group differences and not put this into the error term; however the PROC TTEST method just considers group-to-group diffferences to be part of the overall error term.

What do you think?

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@PaigeMiller agreed.

The example was mostly to show the use of the format to create groups. And since the OP mention ttest use that as an example.

Sort of the "know thy data" before picking the analysis technique.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Dear @PaigeMiller

I wonder if you can help me with the contrast statement,

I want to compare between stage 2 to stage 1,3,4,5 together,

The code is:

proc glm data=sasuser.sasfile010916;

class stage;

model ROA1=stage;

means stage/deponly;

contrast 'Compare 2 vs 1,3,4,5 together' stage 1 1 -4 1 1;

run;

Am I right?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@yael wrote:

Dear @PaigeMiller

I wonder if you can help me with the contrast statement,

I want to compare between stage 2 to stage 1,3,4,5 together,

The code is:

proc glm data=sasuser.sasfile010916;

class stage;

model ROA1=stage;

means stage/deponly;

contrast 'Compare 2 vs 1,3,4,5 together' stage 1 1 -4 1 1;

run;

Am I right?

Following the example in the CONTRAST statement documentation, you'd want

`contrast 'Compare 2 vs 1,3,4,5' stage -0.25 1 -0.25 -0.25 -0.25;`

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@PaigeMiller Thanks for your fast reply and shabat shalom

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

With all due respect to @Rick_SAS, I don't think that book is the place to look for the answer, I don't consider the question posed in this thread to be a multiple comparison question. I'm not sure what reading I would recommend.

The bottom line is that the PROC TTEST treats the analysis as if there are only two groups, the group of interest and all the other groups combined. So the actual group to group variability between "all the other groups combined" is considered by PROC TTEST to be random variation, used in the error term of the analysis. In PROC GLM, the difference betwee all 5 groups is specifically accounted for as the group-to-group variability, and thus it is not lumped into the error term. The comparison of group 2 to the average of all other groups combined is tested against this PROC GLM error term, which is smaller than the error term used by PROC TTEST, because the PROC GLM error term does not have the group-to-group variability included (as the PROC TTEST error term does).

--

Paige Miller

Paige Miller

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. **Registration is now open through August 30th**. Visit the SAS Hackathon homepage.

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.