Help using Base SAS procedures

Adding additional prediction data

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 19
Accepted Solution

Adding additional prediction data

How do I add an addtional predictional data while I perform a proc glm or gen mod?

 

For example: I am running a proc glm on a certain data from year 2008 to 2010 and I want the forecasts of 2011 seperately. I can do this in enterprise guide by going to 'predictions' and adding addtional data.  

 

I'm aware one way is to extend the data from 2008 to 2011 and it will automatically add the forecasts but I wish to get them seperately. 

 

Kindly provide suggestions. 

 

Thank you in advance! 

Varun


Accepted Solutions
Solution
‎11-10-2015 05:23 PM
SAS Super FREQ
Posts: 3,483

Re: Adding additional prediction data

Statisticians call this "scoring" the regression model.

See this article: "Techniques for scoring a regression model in SAS"

View solution in original post


All Replies
Trusted Advisor
Posts: 1,630

Re: Adding additional prediction data

I guess I don't understand what it means "but I wish to get them seperately. "

 

Why can't you just perform the operation the way you described, and then separate the 2011 data from the earlier data?

Occasional Contributor
Posts: 19

Re: Adding additional prediction data

I will have to changes all my databases (Which are lot) if I decide to do that. 

Super User
Posts: 17,912

Re: Adding additional prediction data

Look at PROC SCORE
The example is for PROC REG, but it should work for PROC GLM.
Super User
Posts: 5,093

Re: Adding additional prediction data

If I recall accurately, GLM supports RUN groups.  So use a WHERE statement to subset:

 

where (2008 <= year <= 2010);

run;

 

Don't add a QUIT statement.  To add data, change the WHERE statement and re-run:

 

where (2008 <= year <= 2011);

run;

 

When you're totally done, finish with:

 

quit;

 

It's untested but if memory serves this should work.  Good luck.

Occasional Contributor
Posts: 19

Re: Adding additional prediction data

Correct me if I'm wrong!

 

We can use this only when 2008 to 2011 are present in the database right? 

 

For example If I'm performing regression on data from 2005 to 2011 then I can use the statement where (2008<= year <= 2011) not when the data is from 2005 to 2007. 

Super User
Posts: 5,093

Re: Adding additional prediction data

The WHERE statement will select the observations to use.  So if your WHERE statement refers to a range of values that does not appear in your data set, well, you won't get anything useful.  You won't get an error, but a regression based on 0 observations will not be helpful.

Respected Advisor
Posts: 4,659

Re: Adding additional prediction data

You can get predictions in separate sets by issuing multiple OUTPUT statements in separate run groups:

 

proc glm data=sashelp.class;
model weight = height;
output out=Males(where=(sex="M")) predicted=predWeight;
run;
output out=Females(where=(sex="F")) predicted=predWeight;
run;
quit;
PG
Occasional Contributor
Posts: 19

Re: Adding additional prediction data

This is useful. Thank you. Smiley Happy 

Solution
‎11-10-2015 05:23 PM
SAS Super FREQ
Posts: 3,483

Re: Adding additional prediction data

Statisticians call this "scoring" the regression model.

See this article: "Techniques for scoring a regression model in SAS"

Occasional Contributor
Posts: 19

Re: Adding additional prediction data

This is great! I think it works! Thanks a lot Smiley Happy 

 

Why doesn't the Enterprise Guide use this? 

☑ This topic is solved.

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

Discussion stats
  • 10 replies
  • 409 views
  • 1 like
  • 6 in conversation