The SAS Output Delivery System and reporting techniques

Proc Anova Means ods output

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

Proc Anova Means ods output

Hi All,

 

I am currently trying to run about 30 ANOVAS (and know that I sadly have to crete a new proc anova statement for each model - Unlike with proc ttest) and my question is that I am trying to print the IV means to a seperate dataset for each DV using ODS output, but am not able to get this to work for some reason. Is this just not possible or am I doing something wrong? This is the code that I'm using... 

 

ods output Means=means1;
proc anova data=intern.share_full4;
class lonely;
model age = lonely;
means lonely;
run;

 

I believe that I should also be able to add persist in the ods output statement so that this persists for all 30 ANOVA's like so: ods output Means=means1 (persist); ... But, this also isn't working. Would appreciate any help on either of these.

 

Thanks!  

 

Cody


Accepted Solutions
Solution
‎03-15-2017 12:10 PM
Super User
Posts: 19,772

Re: Proc Anova Means ods output

VNAME()

 

See modification below.

 

data transpose_reg;
set data1;
array r(7) age cvd1 cvd2 cvd3 cvd4 cvd5 cvd6
do i=1 to 7;
reg_var=r(i);
var_name = vname(r(i));
output;
end;
drop age cvd1 cvd2 cvd3 cvd4 cvd5 cvd6;
run;

View solution in original post


All Replies
Super User
Posts: 19,772

Re: Proc Anova Means ods output

Post some sample data. There's rarely a requirement to type out 30 different proc anova's so there should be a straightforward way to automate this and get all tables at once. Otherwise I don't know of a way to stack the ods tables automatically, even a short macro may be one way to deal with this.

Occasional Contributor
Posts: 13

Re: Proc Anova Means ods output

Here's some sample data as a .xlsx. The "lonely" group (which has 3 levels) is being used to predict every variable, with the obvious exception of ID. Thanks.

SAS Super FREQ
Posts: 8,864

Re: Proc Anova Means ods output

Hi:
Another thing to try is correct your ODS OUTPUT statement. Typically, the PERSIST goes in parens before the = sign:
ods output means(persist)=work.mean_out;

cynthia
Super User
Posts: 19,772

Re: Proc Anova Means ods output

You could go either macro route or a transpose. 

 

Heres the macro sample, see end of page. 

http://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/

 

And non macro solution

https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-run-multiple-regres...

 

Occasional Contributor
Posts: 13

Re: Proc Anova Means ods output

Wow, that ended up working. Thanks for the help. Couldn't quite figure out how to get the macro to work, but the transpose worked perfectly well. ODS still wasn't working though and it turned out that I had to put it in the code like so...

 

proc glm data=transpose_reg;
class lonely;
by i;
model reg_var = lonely;
means lonely;
ods output means;
run;

 

For future reference any ideas on how to "i" to be more descriptive? Currently it is just 1-7, which isn't terrible helpful, as without looking at the order that variables were put into the array, this is uninterpretable:

 

data transpose_reg;
set data1;

array r(7) age cvd1 cvd2 cvd3 cvd4 cvd5 cvd6

do i=1 to 7;
reg_var=r(i);
output;
end;
drop age cvd1 cvd2 cvd3 cvd4 cvd5 cvd6;

run;

 

Thanks!

 

Cody

 

Solution
‎03-15-2017 12:10 PM
Super User
Posts: 19,772

Re: Proc Anova Means ods output

VNAME()

 

See modification below.

 

data transpose_reg;
set data1;
array r(7) age cvd1 cvd2 cvd3 cvd4 cvd5 cvd6
do i=1 to 7;
reg_var=r(i);
var_name = vname(r(i));
output;
end;
drop age cvd1 cvd2 cvd3 cvd4 cvd5 cvd6;
run;

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 367 views
  • 5 likes
  • 3 in conversation