Dear Statalist Members,
I really appreciate this platform and I hope someone can help me out with a problem. Currently I am working in a data set were I need to sum up values in the column (percentage_shares_repur) before a specific event/date in another column (DateAnnounced). Please take a look at the example below.
-----------------------
------------------
Listed 100 out of 38546 observation
What I would like is to sum up share repurchases before a DateAnnonced by cusip. The tricky part is that some cusip have multiple DateAnnounced and therefore I had problems using inrange function.
To make the example more concrete. In my attached data set. The sum of (percentage_shares_repur) for cusip "00036110" should become 1.526 + .761+0.0873 =2.3743 (until the DateAnnounced). If we have more DateAnnounced for a certain cusip it needs to sum the values between these DateAnnounced.
Could you please suggest a solution to this problem.
Kind Regards,
Daniel
I really appreciate this platform and I hope someone can help me out with a problem. Currently I am working in a data set were I need to sum up values in the column (percentage_shares_repur) before a specific event/date in another column (DateAnnounced). Please take a look at the example below.
-----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double date str8 cusip float percentage_shares_repur long DateAnnounced float i 6998 "00036110" . . 1 7090 "00036110" 0 . 2 7182 "00036110" 0 . 3 7273 "00036110" 0 . 4 7364 "00036110" 0 . 5 7456 "00036110" 0 . 6 7548 "00036110" 0 . 7 7639 "00036110" 0 . 8 7729 "00036110" 0 . 9 7821 "00036110" 0 . 10 7913 "00036110" 0 . 11 8004 "00036110" 1.5261446 . 12 8094 "00036110" 0 . 13 8186 "00036110" 0 . 14 8278 "00036110" .761035 . 15 8369 "00036110" 0 . 16 8459 "00036110" 0 . 17 8551 "00036110" 0 . 18 8643 "00036110" 0 . 19 8734 "00036110" 0 . 20 8825 "00036110" 0 . 21 8917 "00036110" 0 . 22 9009 "00036110" 0 . 23 9100 "00036110" 0 . 24 9190 "00036110" 0 . 25 9282 "00036110" 0 . 26 9374 "00036110" 0 . 27 9465 "00036110" 0 . 28 9555 "00036110" 0 . 29 9647 "00036110" 0 . 30 9739 "00036110" 0 . 31 9830 "00036110" 0 . 32 9920 "00036110" 0 . 33 10012 "00036110" 0 . 34 10104 "00036110" 0 . 35 10195 "00036110" 0 . 36 10286 "00036110" 0 . 37 10378 "00036110" 0 . 38 10470 "00036110" 0 . 39 10561 "00036110" 0 . 40 10651 "00036110" 0 . 41 10743 "00036110" .0873744 . 42 10835 "00036110" 0 . 43 10926 "00036110" 0 . 44 11016 "00036110" 0 . 45 11108 "00036110" 0 . 46 11200 "00036110" 0 . 47 11221 "00036110" . 11221 48 11291 "00036110" 1.2868333 . 49 11381 "00036110" 0 . 50 11473 "00036110" 0 . 51 11565 "00036110" 0 . 52 11656 "00036110" 0 . 53 7821 "00103010" . . 1 7913 "00103010" . . 2 8004 "00103010" . . 3 8094 "00103010" . . 4 8186 "00103010" 0 . 5 8278 "00103010" 0 . 6 8369 "00103010" 0 . 7 8459 "00103010" 0 . 8 8551 "00103010" 0 . 9 8643 "00103010" 0 . 10 8734 "00103010" 0 . 11 8825 "00103010" 0 . 12 8917 "00103010" .48709205 . 13 8958 "00103010" . 8958 14 9009 "00103010" 0 . 15 9100 "00103010" 0 . 16 9190 "00103010" 0 . 17 9282 "00103010" 0 . 18 9374 "00103010" 0 . 19 9465 "00103010" 0 . 20 9555 "00103010" 0 . 21 9647 "00103010" 1.7903365 . 22 9739 "00103010" 2.547771 . 23 9830 "00103010" .1352265 . 24 9920 "00103010" 1.2186866 . 25 10012 "00103010" 4.021019 . 26 10104 "00103010" 0 . 27 10195 "00103010" 3.189717 . 28 10286 "00103010" 2.3604622 . 29 10378 "00103010" 0 . 30 10470 "00103010" 0 . 31 10561 "00103010" 0 . 32 10651 "00103010" 1.536137 . 33 10743 "00103010" .46035805 . 34 10835 "00103010" 0 . 35 10926 "00103010" 0 . 36 11016 "00103010" 0 . 37 11108 "00103010" 0 . 38 11200 "00103010" 0 . 39 11291 "00103010" 0 . 40 11381 "00103010" .2569373 . 41 11473 "00103010" 0 . 42 11565 "00103010" 0 . 43 11656 "00103010" 0 . 44 9131 "00190710" . . 1 9221 "00190710" 0 . 2 9312 "00190710" 0 . 3 end format %d date format %d DateAnnounced
Listed 100 out of 38546 observation
What I would like is to sum up share repurchases before a DateAnnonced by cusip. The tricky part is that some cusip have multiple DateAnnounced and therefore I had problems using inrange function.
To make the example more concrete. In my attached data set. The sum of (percentage_shares_repur) for cusip "00036110" should become 1.526 + .761+0.0873 =2.3743 (until the DateAnnounced). If we have more DateAnnounced for a certain cusip it needs to sum the values between these DateAnnounced.
Could you please suggest a solution to this problem.
Kind Regards,
Daniel
Comment