I have a data set with companies, which conduct deals. Furthermore, these deals have the variables entry year, exit year, entryy_count and exity_count. Each deal has its own ID.
Here a short outline of my data set
Company | Deal | Entry year | Exit year | Entryy_count | Exity_count | Active_deals |
1 | 1 | 2004 | 2006 | 3 | 2 | 4 |
1 | 2 | 2004 | 2006 | 3 | 2 | 4 |
1 | 3 | 2004 | 2007 | 3 | 3 | 4 |
1 | 4 | 2001 | 2004 | 2 | 1 | 2 |
1 | 5 | 2001 | 2007 | 2 | 3 | 2 |
1 | 7 | 2000 | 2007 | 1 | 3 | 1 |
2 | 8 | ... | ... | ... | ... | |
2 | 9 | ... | ... | ... | ... |
For Deal #1 - #3 the "Active_Deals" Variable should be "4" because these deals are made in 2004 and in addition, one firm is sold (Deal #4) in 2004 by Company # 1. Consequently, 4 deals are active in the investment year 2004 for Company #1.
I tried several commands (e.g. egen and by) but I did not find the right way to calculate the active_deals variable.
I am happy for suggestions.
Regards,
Sebastian
0 Response to How to sum two variables from different observations of the same category
Post a Comment