BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
csetzkorn
Lapis Lazuli | Level 10

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;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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. 

View solution in original post

14 REPLIES 14
Reeza
Super User

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. 

csetzkorn
Lapis Lazuli | Level 10

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;
csetzkorn
Lapis Lazuli | Level 10

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.

 

Reeza
Super User

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. 

Reeza
Super User

The ODS statement goes before your PROC and should be EXACTLY like the example. 

csetzkorn
Lapis Lazuli | Level 10

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.

 

Reeza
Super User

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. 

csetzkorn
Lapis Lazuli | Level 10

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.

 

Reeza
Super User

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.

csetzkorn
Lapis Lazuli | Level 10

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!

 

Reeza
Super User

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. 

csetzkorn
Lapis Lazuli | Level 10
Haha I should have check this. I just simplified the above code. That works fine! Sorry that this was a bot long-wounded (-:
xappppp
Calcite | Level 5

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?

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 14 replies
  • 2196 views
  • 1 like
  • 3 in conversation