Contributor
Posts: 65

# multiple linear regression

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?

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;

Super User
Posts: 11,343

## Re: multiple linear regression

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.

Contributor
Posts: 65

## Re: multiple linear regression

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;

Discussion stats
• 2 replies
• 145 views
• 2 likes
• 2 in conversation