I am facing challenges using tsfill command. I am using Stata 15.1. I am trying to create a company-year panel. The research question looks at the impact of investors on companies. Currently data set the data set has a row each time investors invests in a company. The first investment marks the entry to the investor in the company and the last investment marks the exit. A company can have multiple investors, entering and exiting in any year. I use tsfill command to create a panel for the years investor(s) remain invested in a company. But I have to account for all the amounts investors have invested cumulatively in a company. When I use tsfill to create a company-year panel, I loose the information of other investors (if there are more than 1 investor).
Currently, the data looks like this:
I want data to be in this format:
Kindly suggest proper way for handling this data requirement.Thanks.
Currently, the data looks like this:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(company_id year investor_id amount) 1 2014 11 80 1 2015 11 84 1 2016 11 82 2 2014 23 75 2 2014 25 78 2 2017 23 77 2 2017 25 70 2 2018 25 80 3 2014 11 50 3 2015 23 78 3 2018 23 77 3 2019 11 55 end
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(company_id year total_amount) 1 2014 80 1 2015 84 1 2016 82 2 2014 153 2 2015 153 2 2016 153 2 2017 147 3 2014 50 3 2015 128 3 2016 128 3 2017 128 3 2018 127 3 2019 55 end
Comment