I want to calculate cumulative returns for several event horizons, in the following data I need to create a sum of xstret (excess returns).
The requirement is to generate new columns with desired sum, such sume of xstret [-6,0] , xstret [ -13,0] ......so to [-62,0].
I have got over 4,800 cross-sections/group ids. The following data pertains to first
The following table provides first two cumulative returns
The requirement is to generate new columns with desired sum, such sume of xstret [-6,0] , xstret [ -13,0] ......so to [-62,0].
I have got over 4,800 cross-sections/group ids. The following data pertains to first
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int index long PERMNO int dif float xstretend
index dif PERMNO xstret 1 -60 50032 0.006708 1 -59 50032 0.007209 1 -58 50032 -0.00596 1 -57 50032 0.011661 1 -56 50032 0.020184 1 -55 50032 -0.00938 1 -54 50032 0.003783 1 -53 50032 -0.01444 1 -52 50032 -0.03474 1 -51 50032 -0.0209 1 -50 50032 -9.8E-05 1 -49 50032 0.014929 1 -48 50032 0.002364 1 -47 50032 -0.01301 1 -46 50032 -0.0088 1 -45 50032 0.016493 1 -44 50032 0.001625 1 -43 50032 0.001018 1 -42 50032 0.008057 1 -41 50032 0.009621 1 -40 50032 -0.00601 1 -39 50032 0.010867 1 -38 50032 0.008031 1 -37 50032 -0.00618 1 -36 50032 0.007019 1 -35 50032 0.020857 1 -34 50032 -0.00794 1 -33 50032 0.007665 1 -32 50032 -0.00416 1 -31 50032 0.021693 1 -30 50032 0.019179 1 -29 50032 -0.01019 1 -28 50032 0.008612 1 -27 50032 -0.02132 1 -26 50032 -0.00829 1 -25 50032 -0.0029 1 -24 50032 0.010983 1 -23 50032 0.011594 1 -22 50032 0.012901 1 -21 50032 -0.00595 1 -20 50032 -0.00553 1 -19 50032 -0.01135 1 -18 50032 0.008863 1 -17 50032 0.004165 1 -16 50032 -0.00425 1 -15 50032 -0.00415 1 -14 50032 0.012025 1 -13 50032 -0.01017 1 -12 50032 -0.00325 1 -11 50032 0.006568 1 -10 50032 -0.00698 1 -9 50032 0.003846 1 -8 50032 0.00226 1 -7 50032 0.004613 1 -6 50032 0.012321 1 -5 50032 0.011444 1 -4 50032 -0.00646 1 -3 50032 -0.00434 1 -2 50032 0.00766 1 -1 50032 0.021366 1 0 50032 -0.01774
Code:
index dif PERMNO xstret CAR[-6,0] CAR[-13,0] 1 -60 50032 0.006708 0.024255 0.021148 1 -59 50032 0.007209 0.024255 0.021148 1 -58 50032 -0.00596 0.024255 0.021148 1 -57 50032 0.011661 0.024255 0.021148 1 -56 50032 0.020184 0.024255 0.021148 1 -55 50032 -0.00938 0.024255 0.021148 1 -54 50032 0.003783 0.024255 0.021148 1 -53 50032 -0.01444 0.024255 0.021148 1 -52 50032 -0.03474 0.024255 0.021148 1 -51 50032 -0.0209 0.024255 0.021148 1 -50 50032 -9.8E-05 0.024255 0.021148 1 -49 50032 0.014929 0.024255 0.021148 1 -48 50032 0.002364 0.024255 0.021148 1 -47 50032 -0.01301 0.024255 0.021148 1 -46 50032 -0.0088 0.024255 0.021148 1 -45 50032 0.016493 0.024255 0.021148 1 -44 50032 0.001625 0.024255 0.021148 1 -43 50032 0.001018 0.024255 0.021148 1 -42 50032 0.008057 0.024255 0.021148 1 -41 50032 0.009621 0.024255 0.021148 1 -40 50032 -0.00601 0.024255 0.021148 1 -39 50032 0.010867 0.024255 0.021148 1 -38 50032 0.008031 0.024255 0.021148 1 -37 50032 -0.00618 0.024255 0.021148 1 -36 50032 0.007019 0.024255 0.021148 1 -35 50032 0.020857 0.024255 0.021148 1 -34 50032 -0.00794 0.024255 0.021148 1 -33 50032 0.007665 0.024255 0.021148 1 -32 50032 -0.00416 0.024255 0.021148 1 -31 50032 0.021693 0.024255 0.021148 1 -30 50032 0.019179 0.024255 0.021148 1 -29 50032 -0.01019 0.024255 0.021148 1 -28 50032 0.008612 0.024255 0.021148 1 -27 50032 -0.02132 0.024255 0.021148 1 -26 50032 -0.00829 0.024255 0.021148 1 -25 50032 -0.0029 0.024255 0.021148 1 -24 50032 0.010983 0.024255 0.021148 1 -23 50032 0.011594 0.024255 0.021148 1 -22 50032 0.012901 0.024255 0.021148 1 -21 50032 -0.00595 0.024255 0.021148 1 -20 50032 -0.00553 0.024255 0.021148 1 -19 50032 -0.01135 0.024255 0.021148 1 -18 50032 0.008863 0.024255 0.021148 1 -17 50032 0.004165 0.024255 0.021148 1 -16 50032 -0.00425 0.024255 0.021148 1 -15 50032 -0.00415 0.024255 0.021148 1 -14 50032 0.012025 0.024255 0.021148 1 -13 50032 -0.01017 0.024255 0.021148 1 -12 50032 -0.00325 0.024255 0.021148 1 -11 50032 0.006568 0.024255 0.021148 1 -10 50032 -0.00698 0.024255 0.021148 1 -9 50032 0.003846 0.024255 0.021148 1 -8 50032 0.00226 0.024255 0.021148 1 -7 50032 0.004613 0.024255 0.021148 1 -6 50032 0.012321 0.024255 0.021148 1 -5 50032 0.011444 0.024255 0.021148 1 -4 50032 -0.00646 0.024255 0.021148 1 -3 50032 -0.00434 0.024255 0.021148 1 -2 50032 0.00766 0.024255 0.021148 1 -1 50032 0.021366 0.024255 0.021148 1 0 50032 -0.01774 0.024255 0.021148
Comment