BookmarkSubscribeRSS Feed
Jahanzaib
Quartz | Level 8

I want to run second regression from the predicted value of first regression. I have made it on this paper in order to understand it. Bdr is the dependent variable in first regression and in the second stage the value from first regression is used as predicted bdr as regressor. KakaoTalk_20161213_121417352.jpg

9 REPLIES 9
PGStats
Opal | Level 21

Use an OUTPUT statement in the first regression to get the predicted values into a dataset and use that dataset to run the second regression.

PG
Jahanzaib
Quartz | Level 8
Can you explain more how to connect output from first regression with second regression.
Reeza
Super User

Regression from step 1 creates a data set called reg_results

Pass that to your second regression. 

 

Proc glm data=SASHELP.class;

model weight = age height;

output out=reg_results p=Predict r=Resid;

run;quit;

 

proc glm data=reg_results;

model = ...;

 

 

Jahanzaib
Quartz | Level 8

I have used following regression but it gives an error as shown in Picture. Screenshot 2016-12-14 18.06.36.png

Proc glm data=want1;
model bdr= fam EBITDA_TA MTB LNTA FA_TA RD_TA stdd;
output out=results p=Predict r=Resid;
run;quit;


proc glm data=results;
model cum= predict(bdr) EBITDA_TA MTB LnTA LnTA2 FA_TA RD_TA stdd assmat;
run;

Reeza
Super User

Predict(bdr) -> what is this supposed to represent? 

 

I don't think it does does what you think it does. 

Jahanzaib
Quartz | Level 8
predict(bdr) is the predicted value of bdr which i suppose to get from first level regression. then use that in the second regression as predicted value of bdr.
Reeza
Super User

As I said, it's not doing what you think. 

 

Review your OUTPUT statement from the previous step. 

P=Predict -> what do you think this portion does? 

 

 

 

 

Jahanzaib
Quartz | Level 8
i think it will predict all value of all the variables. moreover i do not understand r=Resid.
Reeza
Super User

Like I mentioned, not what you think. 

 

It it creates a predicted variable called PREDICT. The residuals (predicted - actual) are stored in a variable called Resid. 

Open the dataset and examine if manually or run a proc contents and explore the variables there. 

 

Proc contents data=reg_results;

run;

 

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 ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 9 replies
  • 1878 views
  • 2 likes
  • 3 in conversation