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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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