turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- Proc anova q

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-16-2015 04:07 PM

Hello:

I would like to conduct proc anova tests then use the p-value variables to include in tables.

I would like to do proc anova tests for four variables (estabgroup, message, mode, exemplar) each with a list of covariates which will change over time. So, I'd like to be able to use a macro var for the covarites, covar_list which I'll include in the code.

Letting my list of covariates only include one variable, fns, now my code looks like this:

proc anova data=sample outstat= anova_estab;

class estabgroup ;

model Firm_employee_n=estabgroup ;

run;

proc anova data=sample outstat= anova_mode;

class mode ;

model Firm_employee_n=mode;

run;

proc anova data=sample outstat= anova_message;

class message ;

model Firm_employee_n=message;

run;

proc anova data=sample outstat= anova_exemplar;

class exemplar;

model Firm_employee_n=exemplar;

run;

Will I be able to use a condensed version of code to do this test for the list of covarites? If so, how would it look?

Many thanks for your time and help!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-16-2015 04:29 PM

You need to do something like this

https://communities.sas.com/thread/74943

but instead of the command %put value &value; you want to insert the proper PROC ANOVA call with macro variable &value instead of the variable name.

MightI also be so bold as to comment that from a statistical point of view, you don't want to do 4 different ANOVAs on the same data set. It would be more appropriate in almost every situation I can think of to do one ANOVA with four terms in the right-hand side of the model (or create the proper model somehow)

proc anova data=sample outstat= anova_exemplar;

class variable1 variable2 variable3 variable4;

model Firm_employee_n= variable1 variable2 variable3 variable4;

run;

No macros needed.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-16-2015 04:49 PM

Hi PaigeMiller:

Thanks for all the feedback!

On the proc anova test with four class variables instead of one, i get the follow message:

1641 proc anova data=sample outstat= anova;

1642 class estabgroup message mode exemplar;

1643 model Firm_employee_n=estabgroup message mode exemplar; ;

1644 run;

WARNING: PROC ANOVA has determined that the number of observations in each cell is not equal. PROC

GLM may be more appropriate.

would you know why?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-17-2015 08:12 AM

The SAS error message explained it to you. PROC ANOVA is for balanced designs, where the number of observations in each cell is equal, and you don't have that. So PROC GLM will work better.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-17-2015 09:52 AM

You can stack these CLASS variable vertically together,

data want;

set have(keep=Firm_employee_n estabgroup rename=(estabgroup =group) )

set have(keep=Firm_employee_n message rename=(message =group) )

................

indsname=ind;

indsname=ind;

run;

then use BY statement of proc anova ;

proc anova;

by indsname;

class group;

........

Xia Keshan