Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run PROC LOGISTIC on all variables in your dataset in SAS?

I have a dataset with 300+ variables and I want to perform stepwise selection in PROC LOGISTIC (I understand stepwise selection is a bad idea here but it's not up to me) on all these variables - some of which are numeric and some of which are categorical.

Without typing the name of each of the 300+ variables, how do I write the model statement so that the model is all variables in my data set except for my response variable? How do I write the class statement so that it knows to treat all the categorical variables as categorical?

like image 319
NewNameStat Avatar asked Nov 30 '25 02:11

NewNameStat


1 Answers

You can quickly grab all the headings of your dataset to copy and paste with this:

proc contents data = X short;
run;

This will generate a list that you can copy and paste into your proc logistic statement.

Assuming your class variables are character based you can do the following:

proc contents data = X out=test;
run;

data test; set test; 
if TYPE=2;
run

proc transpose data=test out=test2;
var name;
id name;
run;

proc contents data = test2 short;
run;
like image 50
SniperBro2000 Avatar answered Dec 04 '25 08:12

SniperBro2000



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!