- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;