Hi,
I have the following dataset:
I would like to add the variables ret_L1+ret_L2+...+ret_L`J'. I defined the local macro `J' in the code. How can I modify the last row? Here is what I am running
I have the following dataset:
HTML Code:
permno date ln_ret 10000 1986m1 10000 1986m2 -.2972516 10000 1986m3 .3114361 10000 1986m4 -.1037968 10000 1986m5 -.2518726 10000 1986m6 -.0050378 10000 1986m7 -.0842603 10000 1986m8 -.9555115 10000 1986m9 -.0588405 10000 1986m10 -.2776318 10000 1986m11 .0582689 10000 1986m12 -.4737844 10001 1986m1 10001 1986m2 .0202027 10001 1986m3 .0248877 10001 1986m4 .0098523 10001 1986m5 -.0098523 10001 1986m6 -.0131555 10001 1986m7 -.0102565 10001 1986m8 .0696799 10001 1986m9 -.0030817 10001 1986m10 .0384663 10001 1986m11 .0550598 10001 1986m12 .0148886
I would like to add the variables ret_L1+ret_L2+...+ret_L`J'. I defined the local macro `J' in the code. How can I modify the last row? Here is what I am running
Code:
local J 6 tsset permno date, monthly sort permno date forvalues i = 1(1)`J' { gen ret_L`i' = L`i'.ln_ret } local v ret_L1-ret_L`J' gen cum_ret = exp(sum(`v'))-1
Comment