DATA Step, Macro, Functions and more

put data from an item store into library dataset

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 78
Accepted Solution

put data from an item store into library dataset

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;

 

 


Accepted Solutions
Solution
‎12-18-2016 03:26 AM
Super User
Posts: 17,826

Re: put data from an item store into library dataset

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


All Replies
Super User
Posts: 17,826

Re: put data from an item store into library dataset

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. 

Frequent Contributor
Posts: 78

Re: put data from an item store into library dataset

[ Edited ]

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;
Super User
Posts: 17,826

Re: put data from an item store into library dataset

Frequent Contributor
Posts: 78

Re: put data from an item store into library dataset

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.

 

Super User
Posts: 17,826

Re: put data from an item store into library dataset

[ Edited ]

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. 

Super User
Posts: 17,826

Re: put data from an item store into library dataset

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

Frequent Contributor
Posts: 78

Re: put data from an item store into library dataset

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.

 

Super User
Posts: 17,826

Re: put data from an item store into library dataset

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. 

Frequent Contributor
Posts: 78

Re: put data from an item store into library dataset

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.

 

Super User
Posts: 17,826

Re: put data from an item store into library dataset

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.

Frequent Contributor
Posts: 78

Re: put data from an item store into library dataset

[ Edited ]

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!

 

Solution
‎12-18-2016 03:26 AM
Super User
Posts: 17,826

Re: put data from an item store into library dataset

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. 

Frequent Contributor
Posts: 78

Re: put data from an item store into library dataset

Haha I should have check this. I just simplified the above code. That works fine! Sorry that this was a bot long-wounded (-:
New Contributor
Posts: 3

Re: put data from an item store into library dataset

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?

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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