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
- /
- proc anova

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**.
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 05-02-2022 04:46 PM
(846 views)

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

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

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

Paige Miller

7 REPLIES 7

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

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

Paige Miller

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

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

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

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.

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

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

Paige Miller

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

Thanks, I will try to use glm

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

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

Paige Miller

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

**Available on demand!**

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

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.