SAS: Repeated Estimation of Stepwise Regressions by Group

This post presents a SAS code for estimating regression models by group with a stepwise variable selection.

We use the sashelp.baseball dataset as a sample data which was used in the previous post below.

We assume that work.base2 dataset is prepared, which has the number and name of groups based on Team column. work.base2 is already created in the previous post.

Stepwise Regression with a group name as the model name

Given work.base2 dataset, the following SAS code performs an estimation of stepwise linear regression model. This SAS code is same as that of the previous post except the treatment of a stepwise option.

Repeated regressions by using a do-loop

For repeated estimation of regressions, the following SAS macro code is implemented for retrieving array of group names and multiple estimations are carried out using a do-loop.

The following output is estimation results of stepwise regressions with fixed_var_no = 0.

There are, however, many cases where some variables are fixed in advance. In this case fixed_var_no = k is used, which means that the first n-th variables are always selected. The following output shows this kind of stepwise regressions with fixed variables (nAtBat nHits).

Originally posted on SH Fintech Modeling blog.

Disclosure: Interactive Brokers

Information posted on IBKR Campus that is provided by third-parties does NOT constitute a recommendation that you should contract for the services of that third party. Third-party participants who contribute to IBKR Campus are independent of Interactive Brokers and Interactive Brokers does not make any representations or warranties concerning the services offered, their past or future performance, or the accuracy of the information provided by the third party. Past performance is no guarantee of future results.

This material is from SHLee AI Financial Model and is being posted with its permission. The views expressed in this material are solely those of the author and/or SHLee AI Financial Model and Interactive Brokers is not endorsing or recommending any investment or trading discussed in the material. This material is not and should not be construed as an offer to buy or sell any security. It should not be construed as research or investment advice or a recommendation to buy, sell or hold any security or commodity. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.