Obsidian | Level 7

## proc anova

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
Diamond | Level 26

## Re: proc anova

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
7 REPLIES 7
Diamond | Level 26

## Re: proc anova

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

## Re: proc anova

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

Obsidian | Level 7

## Re: proc anova

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.
Diamond | Level 26

## Re: proc anova

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
Obsidian | Level 7

## Re: proc anova

Thanks, I will try to use glm

Diamond | Level 26

## Re: proc anova

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
Obsidian | Level 7

## Re: proc anova

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.
Discussion stats
• 7 replies
• 847 views
• 1 like
• 3 in conversation