BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Thalitacosta
Obsidian | Level 7

Can you add in the code below the ANOVA output comparaing the averages "LEAF" 2 in 2?

 

proc anova data=tab;

class leaf;

model lgd_m18=leaf;

means leaf/tukey cldiff;

run;

 

Without me having to segregate first, like this:

 

data tab1 tab2 tab3;

set tab;

if leaf <= 2 then output tab1;

if 2 <= leaf <= 3 then output tab2;

if leaf = 1 or leaf = 3 then output tab3;

run;

 

proc anova data=tab1;

class leaf;

model lgd_m18=leaf;

means leaf/tukey cldiff;

run;

 

proc anova data=tab2;

class leaf;

model lgd_m18=leaf;

means leaf/tukey cldiff;

run;

 

proc anova data=tab3;

class leaf;

model lgd_m18=leaf;

means leaf/tukey cldiff;

run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

But I needed the results comparing sheet 1 with 2, 1 with 3, and 2 with 3


This is one run of PROC GLM, where you ask GLM to provide pairwise comparisons of the means of each level. (Or even one run of PROC ANOVA)

--
Paige Miller

View solution in original post

7 REPLIES 7
PaigeMiller
Diamond | Level 26

Without seeing your data, I doubt I can help. Show us the data, please.(And by the way @Thalitacosta, we shouldn't have to consistently ask you to show us the data, this should be done every single time with every single question)

 

And provide more explanation of this, please: "comparaing the averages "LEAF" 2 in 2?"

--
Paige Miller
SteveDenham
Jade | Level 19

I guess I don't know why you are subsetting your data, and then using PROC ANOVA to essentially just do a t test.  Your output from the first example should give a Tukey adjusted confidence interval for the difference between the levels of the variable 'leaf'.

 

If you want a Tukey adjust p value for the difference, shift to PROC GLM, and replace "cldiff" with "pdiff" in the MEANS statement.

 

SteveDenham

 

 

 

Thalitacosta
Obsidian | Level 7
Sorry, I'm Brazilian and my English is pessimistic. The variable used in class = left, in my database has 3 distinct groups: 1, 2 and 3. Using only proc anova: proc anova data=tab; class leaf; model lgd_m18=leaf; run; The results are for the three values. But I needed the results comparing sheet 1 with 2, 1 with 3, and 2 with 3, which I could only segregate the variable "left": data tab1 tab2 tab3; set tabela1; if leaf <= 2 then output tab1; if 2 <= leaf <= 3 then output tab2; if leaf = 1 or leaf = 3 then output tab3; run; proc anova data=tab1; class leaf; model lgd_m18=leaf; means leaf/tukey cldiff; run; proc anova data=tab2; class leaf; model lgd_m18=leaf; means leaf/tukey cldiff; run; proc anova data=tab3; class leaf; model lgd_m18=leaf; means leaf/tukey cldiff; run; proc anova data=tabela1; class leaf; model lgd_m18=leaf; means leaf/tukey cldiff; run; I wanted to know if I can get this last result using some option in proc anova, since sometimes my variable class can have 10 groups, for example, and then it becomes more difficult to segregate.
PaigeMiller
Diamond | Level 26

But I needed the results comparing sheet 1 with 2, 1 with 3, and 2 with 3


This is one run of PROC GLM, where you ask GLM to provide pairwise comparisons of the means of each level. (Or even one run of PROC ANOVA)

--
Paige Miller
Thalitacosta
Obsidian | Level 7
Thanks, I will try to use glm

PaigeMiller
Diamond | Level 26

The MEANS statement in GLM or ANOVA will do this for you, without subsetting the input data

 

By the way, this is why you should explain the big picture of what you are doing in your original question, instead of implying this is some sort of programming issue with bare minimum explanation. But once you clearly told us "But I needed the results comparing sheet 1 with 2, 1 with 3, and 2 with 3", everything becomes clear and it's not a programming issue. So please give us the big picture from now on.

--
Paige Miller
Thalitacosta
Obsidian | Level 7
Sorry, I'm Brazilian and my English is pessimistic. The variable used in class = left, in my database has 3 distinct groups: 1, 2 and 3. Using only proc anova: proc anova data=tab; class leaf; model lgd_m18=leaf; run; The results are for the three values. But I needed the results comparing sheet 1 with 2, 1 with 3, and 2 with 3, which I could only segregate the variable "left": data tab1 tab2 tab3; set tabela1; if leaf <= 2 then output tab1; if 2 <= leaf <= 3 then output tab2; if leaf = 1 or leaf = 3 then output tab3; run; proc anova data=tab1; class leaf; model lgd_m18=leaf; means leaf/tukey cldiff; run; proc anova data=tab2; class leaf; model lgd_m18=leaf; means leaf/tukey cldiff; run; proc anova data=tab3; class leaf; model lgd_m18=leaf; means leaf/tukey cldiff; run; proc anova data=tabela1; class leaf; model lgd_m18=leaf; means leaf/tukey cldiff; run; I wanted to know if I can get this last result using some option in proc anova, since sometimes my variable class can have 10 groups, for example, and then it becomes more difficult to segregate.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 7 replies
  • 1369 views
  • 1 like
  • 3 in conversation