gvkey date RET 10001 19940131 -0.04762 10001 19940228 0 10001 19940331 -0.00429 10001 19940429 -0.14493 10001 19940531 0.067797 10001 19940630 0.107302 10001 19940729 0.072464 10001 19940831 -0.02703 10001 19940930 0.038333 10001 19941031 -0.05405 10001 19941130 -0.04286 10001 19941230 -0.03343 10001 19950131 -0.03125 10001 19950228 -0.02621 10001 19950331 0.006377 10001 19950428 0 10001 19950531 0.05 10001 19950630 0.060317 10001 19950731 0 10001 19950831 -0.0303 10001 19950929 0.04375 10001 19951031 -0.0303 10001 19951130 0.09375 10001 19951229 0.082857 I have a large data set with many gvkey and monthly return(ret) like the above To calculate the annual return from monthly return, I have used the following code. Data annual_returns; set return; return1= 1+ret; if first.date then return2= return1; else return2= return1*(lag(return2)); annual_return=return2-1; by gvkey date; run; But I am not getting the expected result. I tried to use the codes available in the forum but none is giving me the expected result. The formula is given below. APY = (1+r1)*(1+r2) *(1+r3) *(1+r4) *(1+r5) *(1+r6) *(1+r7) *(1+r8) *(1+r9) *(1+r10) *(1+r11) *(1+r12) – 1 Let’s say the twelve monthly returns are 2%, 2.2%, 2.1%, -1.5%, 2%, 2.4%, 1%, -1.2%, -0.5%, 0.7%, 1%, and 1.5%. Using the above monthly returns, we can calculate the annualized returns as follows: APY = (1.02)(1.022)(1.021)(0.985)(1.02)(1.024)(1.01)(0.988)(0.995)(1.007)(1.01)(1.015) – 1 Annualized return = 0.1223 or 12.23% What mistake am I making? What should be the correct code?
... View more