gvkey fyear rd Desired values (KC) 1001 1980 2.5 2.50 1001 1981 3.1 5.10 1001 1982 0.7 4.78 1002 1980 1.2 1.20 1002 1981 5.5 6.46 1002 1982 12.4 17.57 1003 1980 4.6 4.60 1003 1981 2.9 6.58 1003 1982 1.8 7.06 1003 1983 12.45 18.10 1003 1984 15.55 30.03 1003 1985 16.87 40.89 Hi, From the above data, I want to calculate values in the "Desired Value" column. Desired value = 0.8*lag(kc)+rd. Here, for each of the first observation according to gvkey, there is no kc. So, for the first gvkey the equation will be Desired value = 0.8*0+rd. That means, the first gvkey kc is zero. I used the following code Data want; set have; by gvkey fyear; retain kc; if first.gvkey then kc=rd; else kc = 0.8* lag(kc) +rd; run; Problem is that I am not getting the desired result. Could you please help me? What mistakes am I making?
... View more