Go Back   Rhinocerus > Newsgroup > Newsgroup comp.soft-sys.sas

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 07-11-2008, 08:11 PM
data _null_,
Guest
 
Posts: n/a
Default Re: Appending RTF files (PROC LOGISTIC) or maybe macro loops?

As Ya has shown you can keep calling PROCs and have all the OUTPUT
send to the ODS destination in one file.

I noticed that your long list of variables contained a "SAS Variable
List". I thought you might want to consider a program that would
allow you to exploit the "SAS Variable List" by expanding that list
and then calling the PROCs you are interested in.

This is facilitate by PROC TRANSPOSE which is happy to create a list
of names from a VAR statement in any form that it accepts.

I then use a data step and CALL execute to cycle through the list and
issue the PROC and TITLE statements needed. We have seen this
technique many times on SAS-L.

This could all be wrapped in a macro with parameters DATA= RTF= Y=
CATEGORICAL= and CONTINUOUS= etc. to further package this technique if
you are so inclined.

I left off the macro wrapper so as not to disguise the workings of the
basic concept.


**Make data using names that Peter mentioned;
data work.today;
array _a[*] pdem4 pdem9 hcu2 v25 v27 pdem5 ch1 ch5a ch5b ch5c ch5d
ch5e ch5f ch5g;
array _b[*] $1 ch7c ch7d ch7k ch7m ch7o ch7q ch11a ch11b ch11c
ch11d ch11e ch11f ch11g;
array _c[*] ch13 ch14 ch15;
array _d[*] $2 ch17a ch17b ch17c ch17d ch17e ch17f ch17g;
array _e[*] ch20a ch20b ch20c ch20d ch20e ch20f ch20g
ch21 ch26 ch32 ch33 ch35 pvac1a pvac1b pvac1c pvac1d pvac1e
whodec totsources tottalkedto v13 v17 v24 v26 v28 v29
v30a v30b v30c v30d v30e v30f v30g v31;
do id = 1 to 20;
prop_part = rantbl(12345,.5)-1;
do i = 1 to dim(_a);
_a[i] = rannor(12345);
end;
do i = 1 to dim(_b);
_b[i] = substr('ABC',rantbl(12345,1/3,1/3),1);
end;
do i = 1 to dim(_c);
_c[i] = rantbl(12345,.4);
end;
do i = 1 to dim(_d);
_d[i] = substr('ABCDEG',rantbl(12345,1/6,1/6,1/6,1/6,1/6),1);
end;
do i = 1 to dim(_e);
_e[i] = rantbl(12345,.7);
end;
output;
end;
attrib _all_ label = 'Label for this variable';
run;
proc print;
run;


ods rtf file="C:\Documents and Settings\&sysuserid\My
Documents\multinomial.rtf";
ods select ParameterEstimates OddsRatios;
title2 'Multinomial logistic regression';

*Use PROC TRANSPOSE to expand the SAS Variable List;
proc transpose data=work.today(obs=0) out=work.CONTINUOUS;
var pdem4 pdem9 hcu2 v25 v27 pdem5 ch1 ch5a--ch5g;
run;
*proc print;
run;
data _null_;
set work.continuous;
call execute(catx(' ','Title3',quote(catx(': ',_name_,_label_)),';'));
call execute('Proc Logistic data=work.today;');
call execute(cats('model prop_part=',_name_,';'));
call execute('run;');
run;

*Use PROC TRANSPOSE to expand the SAS Variable List;
proc transpose data=work.today(obs=0) out=work.CATEGORICAL;
var ch7c ch7d ch7k ch7m ch7o ch7q ch11a ch11b ch11c ch11d ch11e ch11f ch11g
ch13 ch14 ch15
ch17a ch17b ch17c ch17d ch17e ch17f ch17g
ch20a ch20b ch20c ch20d ch20e ch20f ch20g
ch21 ch26 ch32 ch33 ch35
pvac1a pvac1b pvac1c pvac1d pvac1e
whodec totsources tottalkedto
v13 v17 v24 v26 v28 v29
/* v30a v30b v30c v30d v30e v30f v30g*/ v30: v31;
run;
*proc print;
run;
data _null_;
set work.categorical;
call execute(catx(' ','Title3',quote(catx(': ',_name_,_label_)),';'));
call execute('Proc Logistic data=work.today;');
call execute(catx(' ','Class',_name_,'/param=ref;'));
call execute(cats('model prop_part=',_name_,';'));
call execute('run;');
run;
ods rtf close;
ods select all;


On 7/11/08, Peter Flom <peterflomconsulting@mindspring.com> wrote:
> Fantastic!
>
> I think (correct me if I am wrong) that I'll have to run this separately for the continuous and categorical variables... so that I can put in a CLASS statement for the categorical ones.
>
> But still great, two files instead of dozens
>
> thanks
>
> Peter
>
> -----Original Message-----
> >From: Ya Huang <ya.huang@AMYLIN.COM>
> >Sent: Jul 11, 2008 1:50 PM
> >To: SAS-L@LISTSERV.UGA.EDU
> >Subject: Re: Appending RTF files (PROC LOGISTIC) or maybe macro loops?
> >
> >Make a macro and call many time INSIDE the ODS boundary:
> >
> >ods rtf file = 'c:\personal\consults\al pach\multinomial.rtf';;
> >%macro doit(iv);
> >ods select ParameterEstimates OddsRatios;
> >title2 'Multinomial logistic regression';
> >title3 "&iv";
> >proc logistic data = today;
> > model prop_part = &iv;
> >run;
> >%mend doit;
> >
> > %doit(pdem4);
> > %doit(pdem9);
> > %doit(hcu2);
> > ...
> >
> > %doit(v31);
> >
> >ods rtf close;
> >
> >You can certainly make a macro loop, but for one time deal, I usually
> >just copy and paste :-)
> >
> >Anther way would be to transpose the data so you can use BY var.
> >
> >
> >On Fri, 11 Jul 2008 13:18:20 -0400, Peter Flom
> ><peterflomconsulting@MINDSPRING.COM> wrote:
> >
> >>Hello again
> >>
> >>I am running a large number of bivariate logistic regressions, using ODS

> >SELECT statements to select the output, and ODS RTF to write the file. I
> >would like all the regressions to be in one file.
> >>
> >>What I have now is
> >>
> >>
> >><<<<
> >>ods rtf file = 'c:\personal\consults\al pach\multinomial.rtf';;
> >>%let iv = pdem4;
> >>ods select ParameterEstimates OddsRatios;
> >>title2 'Multinomial logistic regression';
> >>title3 "&iv";
> >>proc logistic data = today;
> >> *class &iv/param = ref;
> >> model prop_part = &iv;
> >>run;
> >>ods rtf close;
> >>>>>>
> >>
> >>I've got a list of independent variables
> >>
> >>pdem4 pdem9 hcu2 v25 v27 pdem5 ch1 ch5a--ch5g
> >>ch7c ch7d ch7k ch7m ch7o ch7q ch11a ch11b ch11c ch11d ch11e ch11f ch11g
> >> ch13 ch14 ch15
> >> ch17a ch17b ch17c ch17d ch17e ch17f ch17g
> >> ch20a ch20b ch20c ch20d ch20e ch20f ch20g
> >> ch21 ch26 ch32 ch33 ch35
> >> pvac1a pvac1b pvac1c pvac1d pvac1e
> >> whodec totsources tottalkedto
> >> v13 v17 v24 v26 v28 v29
> >> v30a v30b v30c v30d v30e v30f v30g
> >> v31
> >>
> >>where those on the top row are continuous and those on the other rows are

> >categorical. (That's why I commented out the class statement).
> >>
> >>Of course, each time I run this, it creates a new file. I could add the

> >macro to the ods rtf statement, but I don't really want to create so many
> >files.
> >>
> >>
> >>Any help appreciated, as always.
> >>
> >>Note that I will be out for a while this afternoon, but will return around

> >5:30 Eastern time. If I don't get back to any responders immediately,
> >that's the reason.
> >>
> >>
> >>Peter
> >>
> >>Peter L. Flom, PhD
> >>Statistical Consultant
> >>www DOT peterflom DOT com

>
>
> Peter L. Flom, PhD
> Statistical Consultant
> www DOT peterflom DOT com
>

Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: PROC FREQ--DATA STEP--MODELING QUESTION data _null_; Newsgroup comp.soft-sys.sas 0 06-06-2007 07:45 PM
Re: reading in multple csv files and exporting to excel via macro Peter Crawford Newsgroup comp.soft-sys.sas 0 11-02-2006 08:59 AM
Re: NEED SAS examples on Conjoint Analysis and MDS Wu Consulting Newsgroup comp.soft-sys.sas 0 10-23-2006 01:29 PM
SCL Joe (was RE: macro structure) Gregg P. Snell Newsgroup comp.soft-sys.sas 0 06-27-2006 07:59 PM
Re: proc report in an external macro Jan Squillace Newsgroup comp.soft-sys.sas 0 11-16-2004 06:34 PM



All times are GMT. The time now is 09:37 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.