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
Statisticians call this "scoring" the regression model.
See this article: "Techniques for scoring a regression model in SAS"
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?
I will have to changes all my databases (Which are lot) if I decide to do that.
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.
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.
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.
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;
This is useful. Thank you. 🙂
Statisticians call this "scoring" the regression model.
See this article: "Techniques for scoring a regression model in SAS"
This is great! I think it works! Thanks a lot 🙂
Why doesn't the Enterprise Guide use this?
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.