Programming the statistical procedures from SAS

How to get means /tukey to show me significant mean difference

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

How to get means /tukey to show me significant mean difference

[ Edited ]

Hello 

 

I'm having an issue with a program of mine. I'm just doing a simple ANOVA test on the mean weights of m&m's with respect to their colors  to see if there is any significant differences in the means across the different colors (it's for a school assignment). I will post my code below:

 

DATA QUESTION5;
INPUT @1 COLOR $ @8 WEIGHT;
DATALINES;
RED    0.946
RED    1.107
RED    0.913
RED    0.904
RED    0.926
RED    0.926
RED    1.006
RED    0.914
RED    0.922
RED    1.052
RED    0.903
RED    0.895
RED    .
RED    .
ORANGE 0.902
ORANGE 0.943
ORANGE 0.916
ORANGE 0.910
ORANGE 0.903
ORANGE 0.901
ORANGE 0.919
ORANGE 0.901
ORANGE 0.930
ORANGE 0.883
ORANGE .
ORANGE .
ORANGE .
ORANGE .
YELLOW 0.929
YELLOW 0.960
YELLOW 0.938
YELLOW 0.933
YELLOW 0.932
YELLOW 0.899
YELLOW 0.907
YELLOW 0.906
YELLOW 0.930
YELLOW 0.952
YELLOW 0.939
YELLOW 0.940
YELLOW 0.882
YELLOW 0.906
BROWN  0.896
BROWN  0.888
BROWN  0.906
BROWN  0.941
BROWN  0.838
BROWN  0.892
BROWN  0.905
BROWN  0.824
BROWN  0.908
BROWN  0.833
BROWN  .
BROWN  .
BROWN  .
BROWN  .
TAN    0.845
TAN    0.909
TAN    0.873
TAN    0.902
TAN    0.956
TAN    0.959
TAN    0.916
TAN    0.822
TAN    .
TAN    .
TAN    .
TAN    .
TAN    .
TAN    .
GREEN  0.935
GREEN  0.903
GREEN  0.865
GREEN  0.822
GREEN  0.871
GREEN  0.905
GREEN  0.905
GREEN  0.852
GREEN  0.965
GREEN  0.898
GREEN  .
GREEN  .
GREEN  .
GREEN  .
;
PROC GLM DATA = QUESTION5;
CLASS COLOR;
MODEL WEIGHT = COLOR;
MEANS COLOR /TUKEY;
MEANS COLOR;
RUN;

Now the problem is, on my results page, which is attached as a PDF file, is showing the results as if I had told it to do a confidence interval estimate on all the means.

 

Basically, what I need the program to do, is show me the results of the Tukey test with the colored bars showing which means are significantly different. For example: 

tukey.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

However, I do not understand why the code above will not do what I want it to, as I've talked to peers in my class and they don't see anything wrong with the code itself. Let me know what you think. 

 

Thanks. 

 

 

 


Accepted Solutions
Solution
‎04-15-2018 11:52 AM
PROC Star
PROC Star
Posts: 404

Re: How to get means /tukey to show me significant mean difference

Posted in reply to yoozername

Try

 

PROC GLM DATA = QUESTION5;
CLASS COLOR;
MODEL WEIGHT = COLOR;
LSMEANS COLOR / adjust=TUKEY lines stderr;
RUN;

View solution in original post


All Replies
Solution
‎04-15-2018 11:52 AM
PROC Star
PROC Star
Posts: 404

Re: How to get means /tukey to show me significant mean difference

Posted in reply to yoozername

Try

 

PROC GLM DATA = QUESTION5;
CLASS COLOR;
MODEL WEIGHT = COLOR;
LSMEANS COLOR / adjust=TUKEY lines stderr;
RUN;
New Contributor
Posts: 2

Re: How to get means /tukey to show me significant mean difference

A version of this got it to work for me. All I had to do was: 

 

PROC GLM DATA = QUESTION5;
CLASS COLOR;
MODEL WEIGHT = COLOR;
MEANS COLOR /TUKEY LINES;
RUN;

 

When the cell sizes are unequal, which in my data set they are, SAS defaults to the CLDIFF option of the MEANS statement, unless you explicitly tell it to express significant mean differences with the LINES statement. 

 

Thank you for the help. 

Super User
Posts: 13,583

Re: How to get means /tukey to show me significant mean difference

Posted in reply to yoozername

Is the objective to draw a plot similar to the one you show?

Then you will have to tell us the components of that graph.

 

The plots in GLM are not going to give you something like that directly. You likely will have to create a data set and use a graphing procedure like Proc SGplot.

PROC Star
PROC Star
Posts: 404

Re: How to get means /tukey to show me significant mean difference

GLM can do that plot style now. It's a recent addition: Graphs for multiple comparisons of means: The lines plot

 

Super User
Posts: 10,787

Re: How to get means /tukey to show me significant mean difference

Posted in reply to yoozername

@Rick_SAS also wrote a blog about  m&m's probability distribution with respect to their colors  , Maybe he could give you a hint .

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 158 views
  • 1 like
  • 4 in conversation