This question is related to this post. Here an item store is created as part of proc glmselect. How can I persist the item store as a library's dataset (SomeLib.DatasetName). Something like this, related to the aforementioned post, does not work:
Data SomeLib.DatasetName; Set work.ScoreExample; run;
An item store can persist in a library. Your storing it in work but can assign it to a permanent library. I'm not seeing the issue.
Is it not remaining between sessions?
It's possibly debatable about storing parameters in a format that's not modifiable by users but I'm sure you can see the rational for such an implementation.
If that's what you want why not capture the ParameterEstimate table?
I think you need to be more explicit in what you're looking for, as it's not clear.
Thanks. Sorry I am still a SAS newby. Can you please provide some code example?
This is a code example, which does not work:
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; Data SomeLib.DatasetName; Set work.ScoreExample; run;
I am sorry but I do not get this to work. If you try:
proc GLMSELECT data=sashelp.cars; model msrp = Cylinders EngineSize Horsepower Length MPG_City MPG_Highway Weight Wheelbase; store work.ScoreExample; run; ods output work.ScoreExample = work.DataSet;
There is no work.DataSet. Ultimately, I would like to persist DataSet in a library (not Work obviously) to run the model against some new data in the future. Any idea to persist the model as a dataset for another run would be very much appreciated. Thanks.
Reread the note again. It's exactly what you want, including the ODS statement. You should be able to run the code in the example.
Edit: Apparently this is one example you can't run, my mistake.
The ODS statement goes before your PROC and should be EXACTLY like the example.
This:
ods output work.ScoreExample = work.DataSet; proc GLMSELECT data=sashelp.cars; model msrp = Cylinders EngineSize Horsepower Length MPG_City MPG_Highway Weight Wheelbase; store work.ScoreExample; run;
does not work either (no work.DataSet produced). Am I missing something. Could you please provide some working code example? Thanks.
I was being literal when I said exactly 🙂
ods output ParameterEstimates=parms; proc GLMSELECT data=sashelp.cars; model msrp = Cylinders EngineSize Horsepower Length MPG_City MPG_Highway Weight Wheelbase; store work.ScoreExample; run;
The table called Parms will have the parameter estimates.
It still does not achieve what I want (see linked post in question). This is the code:
ods output ParameterEstimates=parms; proc GLMSELECT data=sashelp.cars; model msrp = Cylinders EngineSize Horsepower Length MPG_City MPG_Highway Weight Wheelbase; store work.ScoreExample; run; data NewData; Horsepower = 200; Wheelbase = 100; output; Horsepower = 250; Wheelbase = 110; output; Horsepower = 180; Wheelbase = 95; output; run; proc plm restore=parms; score data=NewData out=Pred; /* evaluate the model on new data */ run;
The intention is to score the model using:
proc plm restore=parms;
from the data set params.
From what I can see, you already had that solution with the STORE statement. Your question here was how to view the data in the item store, via your subject line -> put data from an item store into a library dataset. You seem to have two requirements that you want satisfied at once, which doesn't seem possible within this model of scoring. Without understanding your motivation or business problem, workarounds can't be suggested.
My interpretation of your questions:
1. How to score a data set (GLMSELECT w/ STORE + PROC PLM) - previous question
2. Estimates table that can be viewed as a dataset (ODS table) - this question
Use the PARMS table for #1 and use the ScoreExample for #2.
ods output ParameterEstimates=parms;
proc GLMSELECT data=sashelp.cars;
model msrp = Cylinders EngineSize Horsepower Length
MPG_City MPG_Highway Weight Wheelbase;
store work.ScoreExample;
run;
title 'Parameter Estimates Table';
proc print data=parms;
run;
title;
data NewData;
Horsepower = 200; Wheelbase = 100; output;
Horsepower = 250; Wheelbase = 110; output;
Horsepower = 180; Wheelbase = 95; output;
run;
proc plm restore=ScoreExample;
score data=NewData out=Pred; /* evaluate the model on new data */
run;
If this is an issue for you, feel free to add it to the Ideas/Ballot suggestions for the next release of SAS.
I think there is a missunderstanding. Given this original code:
ods output ParameterEstimates=parms; proc GLMSELECT data=sashelp.cars; model msrp = Cylinders EngineSize Horsepower Length MPG_City MPG_Highway Weight Wheelbase; store work.ScoreExample; run; title 'Parameter Estimates Table'; proc print data=parms; run; title;
I want to persist work.ScoreExample, which is an item store, in some form (maybe one can persist item stores?) so that I can read this persisted object/dataset/itemstore later on (e.g. in a different program). I was fixated on storing the work.ScoreExample as dataset in a library (e.g. as SomeLibrary.PersistedModelDataset where work.ScoreExample => SomeLibrary.PersistedModel) so that I can do something like this in the future/in a different program:
data NewData; Horsepower = 200; Wheelbase = 100; output; Horsepower = 250; Wheelbase = 110; output; Horsepower = 180; Wheelbase = 95; output; run; proc plm restore=SomeLibrary.PersisteModelDataset; score data=NewData out=Pred; /* evaluate the model on new data */ run; proc print data=Pred labels; run;
Now IMHO this is a fairly basic requirement. If SAS does not allow me to persist models for later 'execution' it would be pretty useless. I hope this makes my requirement clearer and there is a solution to persit a model created via proc glmselect so that it can be applied to another dataset later on (i.e. in a different program). Thanks!
An item store can persist in a library. Your storing it in work but can assign it to a permanent library. I'm not seeing the issue.
Is it not remaining between sessions?
It's possibly debatable about storing parameters in a format that's not modifiable by users but I'm sure you can see the rational for such an implementation.
I would like continue about this topic. Item Store file seems to be invisible in library even it can be seen in windows directory. Any one shed some lights on that?
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: