ODS and Base Reporting

Build reports by using ODS to create HTML, PDF, RTF, Excel, text reports and more!
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
chavens
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

6 REPLIES 6
Reeza
Super User

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.

chavens
Fluorite | Level 6

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.

Cynthia_sas
SAS Super FREQ
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
Reeza
Super User

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...

 

chavens
Fluorite | Level 6

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

 

Reeza
Super User

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;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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