DATA Step, Macro, Functions and more

linear regression model, force independent variable in then do both forward and back stepping

Reply
Super Contributor
Posts: 336

linear regression model, force independent variable in then do both forward and back stepping

please let me know whether my code is correct for this purpose

any other advice?

thanks

proc stepwise data =have ;
 model money= invar condum1 condum2 condum3 / forward;	 run;
proc stepwise data =have ;
 model money= invar condum1 condum2 condum3 / backward;	 run;
Super User
Posts: 17,963

Re: linear regression model, force independent variable in then do both forward and back stepping

No, it's not correct.

 

There's no proc stepwise, I assume you meant reg?

Neither of those force an independent variable to be included, use the INCLUDE option on the model statement to force a variable to be included. 

 

You don't need multiple procs, proc reg can handle multiple MODEL statements. 

Super Contributor
Posts: 336

Re: linear regression model, force independent variable in then do both forward and back stepping

Super User
Posts: 17,963

Re: linear regression model, force independent variable in then do both forward and back stepping

I can't find anything in the documentation to support a stepwise procedure. 

 

If it's a custom proc you'll need to contact the authors for support.

 

https://support.sas.com/documentation/onlinedoc/stat/indexproc.html#stat141

 

If you find the documentation please post it here. 

Super Contributor
Posts: 336

Re: linear regression model, force independent variable in then do both forward and back stepping

 

The author said,

***************

Stepwise Regression Using SAS

In this example, the lung function data will be used again, with two separate analyses.

o Analysis 1: Determining which independent variables for the father (**bleep**e,

fheight, fweight) significantly contribute to the variability in the father’s (ffev1)?

o SAS commands are:

Proc STEPWISE;

Model ffev1=**bleep**e fheight fweight;

Title 'Stepwise regression of father data';

Run;

 

another report:

https://www.stat.wisc.edu/~yandell/software/sas/linmod.html

Stepwise Regression

There is a stepwise model selection regression method. It works something like doing a series of proc regs, but the computer automatically makes the model choices of entry and elimination. Watch out! Be sure you know what this is doing for you (and to you).

proc stepwise;
   model y = x1 x2 x3;

Here are model options for the means of selection and elimination:

   model y = x1 x2 x3 / forward;	/* forward selection */
   model y = x1 x2 x3 / backward;	/* backward elimination */
   model y = x1 x2 x3 / stepwise;	/* forward in & backward out */
   model y = x1 x2 x3 / maxr stop=4;	/* like stepwise, but using R^2 */

The cheapest methods are backward (or b) and forward (or f). The stepwise option (the default) is not much more costly, and a good idea in practice, as it checks back and forth. The maxr option is much more expensive, but does consider pairs of variables in ways possibly missed by stepwise; the stop=4 option to maxr only considers models with 4 or fewer variables, at considerable time savings. There is an alternative to maxr (called minr) which is even more costly.

   model y = x1 x2 x3 / noint;	     /* no intercept */
   model y = x1 x2 x3 / slentry=0.5; /* signif. level for selection */
   model y = x1 x2 x3 / slstay=0.1;  /* signif. level for elimination */
   model y = x1 x2 x3 / include=2;   /* force in first 2 variables */
   model y = x1 x2 x3 / start=2;     /* start with 2 variables */
   model y = x1 x2 x3 / details;     /* more details of R^2, F stats */

 

Super User
Posts: 17,963

Re: linear regression model, force independent variable in then do both forward and back stepping

You realize that's a 20+ year old webpage? 1995? 

I can't find a single SAS reference to it anywhere, including Lexjansen.com which goes back a long way. 

 

Regardless, you can get what you want out of proc REG. 

 

If if you want help with proc stepwise contact support@sas.com. I'd be interested in their response. 

 

Ask a Question
Discussion stats
  • 5 replies
  • 266 views
  • 0 likes
  • 2 in conversation