BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
varun1220
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Statisticians call this "scoring" the regression model.

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

View solution in original post

10 REPLIES 10
PaigeMiller
Diamond | Level 26

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?

--
Paige Miller
varun1220
Fluorite | Level 6

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

Reeza
Super User
Look at PROC SCORE
The example is for PROC REG, but it should work for PROC GLM.
Astounding
PROC Star

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.

varun1220
Fluorite | Level 6

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. 

Astounding
PROC Star

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.

PGStats
Opal | Level 21

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
varun1220
Fluorite | Level 6

This is useful. Thank you. 🙂 

Rick_SAS
SAS Super FREQ

Statisticians call this "scoring" the regression model.

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

varun1220
Fluorite | Level 6

This is great! I think it works! Thanks a lot 🙂 

 

Why doesn't the Enterprise Guide use this? 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

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.

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
  • 10 replies
  • 1305 views
  • 1 like
  • 6 in conversation