turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- multiple linear regression

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-28-2017 05:13 PM

I need to do a linear regression. I have about 30 independent variables in a sas data set. Is there a way to put those variables in the model statement without typing them?

LN_ADJ_Cost ADH CFA Pneu Diabetes ........and much more columns

465 1 1 1 0

543 0 1 1 1

.

.

.

.

proc reg data=cost;

model LN_ADJ_Cost= ADH CFA Pneu Diabetes .......... / selection=backward sls=0.5 collin VIF;

run; quit;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to zhuxiaoyan1

06-28-2017 06:20 PM

I am assuming your variables weren't named ahead of time to use the Var1 - Var30 list notation.

If your variables have common name stems, the first letters are in common the you could use the : variable list notation ADH: would include all variables whose names start with ADH.

If the variables are next to each other in the data set such as column 5 through (something larger than 5) you can use the double dash to indicate them Var1 -- adh57 would get all the variables adjacent with var1 and adh57 included. If you have multiple blocks you could use more than one set of these: Var1 -- adh57 pdq -- xyz would the variables from pdq to xyz that are adjacent to the list from the first bit.

If some of your variables are named Varxx to Varyy with x and y numers you can use Varxx-Varyy mixed with the other lists bits.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ballardw

07-05-2017 10:21 AM

this is nice But I got another approach. Since my independent vars change as data change. I create a macro var and store the independent vars in a macro var, then I don't have to worry about this even my data change.

proc contents daa=For_Reg out=stuff;

run;

proc sql noprint;

select distinct name

into Var separated by ' '

from stuff whewe type=2 and name not EQ 'LN_ADJ-Cost';

quit;