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

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
ballardw
Super User

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;

View solution in original post

15 REPLIES 15
yael
Quartz | Level 8

@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 

PaigeMiller
Diamond | Level 26

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

http://documentation.sas.com/?cdcId=statcdc&cdcVersion=14.2&docsetId=statug&docsetTarget=statug_glm_...

 

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
ballardw
Super User

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;

yael
Quartz | Level 8

@ballardw Thanks for your answer. You meant to format stage firstgroup and not format state firstgroup, right?

ballardw
Super User

@yael wrote:

@ballardw Thanks for your answer. You meant to format stage firstgroup and not format state firstgroup, right?


Correct

PaigeMiller
Diamond | Level 26

@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
ballardw
Super User

@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.

yael
Quartz | Level 8

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?

PaigeMiller
Diamond | Level 26

@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
yael
Quartz | Level 8

@PaigeMiller Thanks for your fast reply and shabat shalom

yael
Quartz | Level 8

Dear @PaigeMiller, I understand that I should use PROC GLM instead of TTEST because of the error terms (if I compare more than 2 groups). I really want to understand it deeply. Can you recommand what is the specific subject that I have to look for in order to get more understanding about it? Thanks

Rick_SAS
SAS Super FREQ

The area of study is called "multiple comparisons." I would start with the PROC GLM doc. If you want a book, I highly recommend Multiple Comparisons and Multiple Tests by Westfall, Tobias, and Wolfinger.

PaigeMiller
Diamond | Level 26

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Discussion stats
  • 15 replies
  • 16761 views
  • 12 likes
  • 5 in conversation