Hello, I have a dataset like this. data temp.database ;
input
YEAR ID SALE;
datalines;
2000 001 23
2001 001 25
2002 001 28
2003 001 30
2004 001 32
2005 001 40
2000 002 23
2001 002 25
2002 002 28
2003 002 30
2004 002 32
2005 002 40
;
run; What I want is like this data temp.database ;
input
YEAR ID SALE BETA;
datalines;
2000 001 23 /* here it is empty as there are no value for previous year */
2001 001 25
2002 001 28
2003 001 30 0.3 /*the value I just make up, but it should be the coefficient from regressing SALE in 2000,2001,2002,2003 on the YEAR value (2000,2001,2002,2003)*/
2004 001 32 0.4 /*Again, this BETA should be the coefficient from regressing SALE in 2001,2002,2003,2004 on YEAR value 2001,2002,2003,2004 */
2005 001 40 0.5 /*Again, this BETA should be the coefficient from regressing SALE in 2002,2003,2004,2005 on YEAR value 2002,2003,2004,2005 */
2000 002 23
2001 002 25
2002 002 28
2003 002 30 0.2
2004 002 32 0.3
2005 002 40 0.4
;
run; If it is in a regression model, it will be like this (use obs in 2003 as example) [SALE in 2000 [2000 SALE in 2001 = BETA* 2001 + residual SALE in 2002 2002 SALE in 2003] 2003] Hope this makes sense to you. How can I capture this BETA and residual respectively?
... View more