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

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. 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

Try

 

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

View solution in original post

5 REPLIES 5
sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

Try

 

PROC GLM DATA = QUESTION5;
CLASS COLOR;
MODEL WEIGHT = COLOR;
LSMEANS COLOR / adjust=TUKEY lines stderr;
RUN;
yoozername
Calcite | Level 5

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. 

ballardw
Super User

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.

sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

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

 

Ksharp
Super User

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

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
  • 5 replies
  • 10018 views
  • 1 like
  • 4 in conversation