Proc anova q

Reply
Frequent Contributor
Posts: 131

Proc anova q

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!

Trusted Advisor
Posts: 1,789

Re: Proc anova q

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.

Frequent Contributor
Posts: 131

Re: Proc anova q

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?

Trusted Advisor
Posts: 1,789

Re: Proc anova q

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.

Super User
Posts: 9,867

Re: Proc anova q

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

Ask a Question
Discussion stats
  • 4 replies
  • 379 views
  • 3 likes
  • 3 in conversation