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
- /
- SAS Programming
- /
- Base SAS Programming
- /
- how to perform model selection

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

12-05-2015 05:01 PM - edited 12-05-2015 05:02 PM

Dear all,

I am not very clear on how to apply forward stepwise procedure by using AIC in SAS to select a model, and of which is highly recommended by my professor, so I want to try to apply it.

e.g.performing forward stepwise procedure in model selection.

model (1): y=x1

model (2): y=x1+x2

My reasoning for the codes: (1) performing forward stepwise selection and getting AIC value of model (1)

(2) performing forward stepwise selection and getting AIC value of model (2)

(3) comparing the AIC value output form model (1) and (2), and choosing the model corresponding to a lower AIC value

**Could anybody check whether my thingking path is correct or not?**

** If it is correct, I think the codes are also not well-formulated, because actually I have five more predictor variables. If checking the AIC value one by one, there will be too much repeated work. In this case, I will consider writting a macro, but I don't know how to do currently, could anyone offer me a similiar example on writting a macro for a model selection? **

**If my thingking path is wrong, could anyone tell me the correct solution of using stepwise procedure to make a model selection by checking the AIC?**

**Another question is that, in my dataset, there are both categorical variables and continuous variables and I want to make a model selection containing both cases of variables. My initial idea is to convert categorical variables to numeric, for example, male=0; female=1, but after convertion, the log came up with:**

**WARNING: No variables specified for an SSCP matrix. Execution terminating.**

**I suspect my solution is wrong, so could anyone offer me some information on how to deal with categorical variable in a multiple regression model? **

*performing forward stepwise selection and getting AIC value of model (1) proc reg data=have_1 outest=want_1; model y = x1 /selection=forward aic; run; *print AIC value; proc print data=want_1; run; *performing forward stepwise selection and getting AIC value of model (2) proc reg data=have_2 outest=want_2; model y = x1, x2 /selection=forward aic; run; *print AIC value; proc print data=want_2; run;

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

Posted in reply to DingDing

12-05-2015 06:39 PM

If you're testing multiple models and capturing the AIC, which I think you're missing the TABLEOUT option for from a previous question, you may want to use a macro method.

Here's a basic intro on how to do that.

If you're dealing with categorical variables you need to convert them to binary variables or use PROC GLM with them specified as a class variable. If you have time, though you should make the time, the SAS Statistical course is free and will walk you through how to perform a regression and what to look for and how to deal with categorical variables. There are entire courses on this subject so I'm not going to bother trying to explain it here.

Here's a basic intro on how to do that.

If you're dealing with categorical variables you need to convert them to binary variables or use PROC GLM with them specified as a class variable. If you have time, though you should make the time, the SAS Statistical course is free and will walk you through how to perform a regression and what to look for and how to deal with categorical variables. There are entire courses on this subject so I'm not going to bother trying to explain it here.

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

Posted in reply to Reeza

12-06-2015 04:23 AM

Thank you for your response, dear Reeza, but one more thing I want to confirm is that whether my reasoning of the codes is correct for model selection?

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

Posted in reply to DingDing

12-05-2015 10:12 PM

You can do forward model selection based on AIC with proc glmselect. Name your categorical variables in the class statement, as in this outline:

proc glmselect data=have;

class gender;

model y = x1 x2 gender / selection=forward(choose=aicc);

run;

Check the documentation for many more options.

PG