Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Proc Logistic 1

Status
Not open for further replies.

stats777

Technical User
Feb 10, 2009
6
0
0
US
Hi ,

I'd like to run logistic regressions on a data set. However there are more than 100 covariates. I wonder whether macro would help to make the process more efficient.
I am using

proc logistic descending;
model a = b c1;
run;

(given there are 100 c1, all come with different variable names). I want to run each logistic regression one at a time. eg.
1st model a=b c1;
2nd model a=b f;
..
..
up to 100 but only the 2nd variable varies.

Is there a way to do it..
A big thank you for any experts who can help!

J
 
proc logistic doesn't have an option to cycle through variable names...but you can use a macro, all you need is a macro variable with all the var names you want to test (Varlist):

%macro logisitic();
%let Varlist = c1 c2 c3 ... c100;
%let i = 1;
%let CurrVar = %scan(&Varlist., &i.);
%do %until (&CurrVar. = );
proc logisitc data=[yourdata] descending;
model a = &CurrVar.;
run;
%let i = %eval(&i. + 1);
%end;
%mend;

%logistic;

 
Thanks so much Sastronaut!

If my varables are of different names, I had to list them in macro variable? as in

%let Varlist=c1,f,g,r..etc

I do have some fixed variables, I would make them as macro variables. will that work? here are my code, correct me if i am wrong. I need some explanation too.

%macro logisitic();
%let Varlist = c1 c2 c3 ... c100; /*all of my 100 predictors aren't of the order c1, c2 ..c100. they are in different names, how do i go about that*/

%let i = 1;
%let CurrVar = %scan(&Varlist., &i.); /*need explanation here*/
%let v1=N;
%let v2=M;
%do %until (&CurrVar. = ); /*here is to DO until CurrenVar= "blank"? */
proc logisitc data=[yourdata] descending;
model a = &N &M &CurrVar.;
run;
%let i =%eval(&i. + 1); * what does it do here? *
%end;
%mend;

%logistic; * this is to invoke macro? *


Many thanks

J



 
%let Varlist=c1,f,g,r..etc

I do have some fixed variables, I would make them as macro variables. will that work? here are my code, correct me if i am wrong. I need some explanation too.

%macro logisitic();
%let Varlist = c1 c2 c3 ... c100; /*all of my 100 predictors aren't of the order c1, c2 ..c100. they are in different names, how do i go about that*/

%let i = 1;
%let CurrVar = %scan(&Varlist., &i.); /*need explanation here --> scan through the variable list, 1 variable at a time, the &i. points to the i-th variable in the list*/
%let v1=N;
%let v2=M;
%do %until (&CurrVar. = ); /*here is to DO until CurrenVar= "blank"? --> correct, cycle through the variable list until there are no more variables*/
proc logisitc data=[yourdata] descending;
model a = &N &M &CurrVar.;
run;
%let i =%eval(&i. + 1); * what does it do here? --> this increments i so that the next variable name can be accessed*
%end;
%mend;

%logistic; * this is to invoke macro? --> you got it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top