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
- /
- persist fitted model produced by proc glmselect

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-16-2016 04:21 AM

Hi there,

I would like to persist the model (formula) produced by proc glmselect like so:

PROC GLMSELECT DATA = WORK.Training TESTDATA = WORK.Test; class AW LN PM(ref="FP"); MODEL Q = FN DR AW LN PM / selection = none stb showpvalues; ods output "Fit Statistics" = WORK.Model_Fit "Parameter Estimates" = WORK.ParameterEstimates Nobs = WORK.Nobs; RUN;

A cumbersome way would be to persits and parse the parameters in WORK.ParameterEstimates and then create a dynamic datastep to apply the formula to unseen data.

Surely there must be a simpler way? Any feedback would be very much appreciated. Thanks a lot.

Christian

Accepted Solutions

Solution

12-16-2016
11:26 AM

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

12-16-2016 07:33 AM

The blog post that Reeza mentions explains the STORE statement, which saves a model into a SAS "itemstore".

You can then use PROC PLM to score the model. See the blog for details and for links to documentation and papers.

The following example is a small modification of the code in the blog:

```
proc GLMSELECT data=sashelp.cars;
model msrp = Cylinders EngineSize Horsepower Length
MPG_City MPG_Highway Weight Wheelbase;
store work.ScoreExample; /* store the model */
quit;
/* selected model contains two explanatory variables:
Horsepower and Wheelbase */
data NewData;
Horsepower = 200; Wheelbase = 100; output;
Horsepower = 250; Wheelbase = 110; output;
Horsepower = 180; Wheelbase = 95; output;
run;
proc plm restore=work.ScoreExample;
score data=NewData out=Pred; /* evaluate the model on new data */
run;
proc print data=Pred labels;
run;
```

All Replies

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

12-16-2016 04:34 AM

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

12-16-2016 05:00 AM

Thanks. I am aware of the SCORE statement but could you please provide some code top see how this would work in my described use case? Thanks.

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

12-16-2016 05:32 AM

Here is an overview of scoring models in SAS.

It depends a bit on your version but CODE is my current preference.

http://blogs.sas.com/content/iml/2014/02/19/scoring-a-regression-model-in-sas.html

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

12-16-2016 07:06 AM

Thanks I am using version current version: 9.04.01M3P062415 and was aware of the quoted post. However, the outest option does not exist for PROC GLMSELECT IMHO. Some example code would be very much appreciated!

Solution

12-16-2016
11:26 AM

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

12-16-2016 07:33 AM

The blog post that Reeza mentions explains the STORE statement, which saves a model into a SAS "itemstore".

You can then use PROC PLM to score the model. See the blog for details and for links to documentation and papers.

The following example is a small modification of the code in the blog:

```
proc GLMSELECT data=sashelp.cars;
model msrp = Cylinders EngineSize Horsepower Length
MPG_City MPG_Highway Weight Wheelbase;
store work.ScoreExample; /* store the model */
quit;
/* selected model contains two explanatory variables:
Horsepower and Wheelbase */
data NewData;
Horsepower = 200; Wheelbase = 100; output;
Horsepower = 250; Wheelbase = 110; output;
Horsepower = 180; Wheelbase = 95; output;
run;
proc plm restore=work.ScoreExample;
score data=NewData out=Pred; /* evaluate the model on new data */
run;
proc print data=Pred labels;
run;
```

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

12-16-2016 10:48 AM

Hi Rick,

Thanks this works great in isolation but for some unexplainable reason not for my ecxample, which is inside a macro:

PROC GLMSELECT DATA = WORK.Training TESTDATA = WORK.Test; class AW LN PM(ref="FP"); MODEL Q = FN DR AW LN PM / selection = none stb showpvalues; store work.ScoreExample; ods output "Fit Statistics" = WORK.Model_Fit "Parameter Estimates" = WORK.ParameterEstimates Nobs = WORK.Nobs; RUN;

When I say it does not work, I cannot see a dataset work.ScoreExample. Any ideas?

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

12-16-2016 11:06 AM

As discussed in the blog post, the model is not stored in a data set. It is stored in an ITEM STORE. Item stores are explained on p. 3 and p. 6 of the Tobias and Cai (2010) paper that is linked to in the blog post. As it says on p. 6 of Tobias and Cai, you can use the SHOW statement in PROC PLM to display an item store.