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
- /
- How to get means /tukey to show me significant mean difference

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-30-2018 03:12 PM
(10497 views)

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:

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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

Try

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

5 REPLIES 5

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

Try

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

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

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.

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

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.

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

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

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.