Hello!
I have a set of firms for the sample period 2010-2019 (some firms may have less than 10 years' records), there is a variable "first", for each firm-year observation. It is an indicator variable that =1 if it is the first time the firm meet some condition. A firm can only be "first" once throughout the sample period, and it is possible that some firms would never be "first" in the sample period. I want to delete all the observations after the year the firm coded 1 for "first", how can I achieve this?
Here is some data:
And after deletion I would like the data looks like this:
Thanks a lot for any kind help!
I have a set of firms for the sample period 2010-2019 (some firms may have less than 10 years' records), there is a variable "first", for each firm-year observation. It is an indicator variable that =1 if it is the first time the firm meet some condition. A firm can only be "first" once throughout the sample period, and it is possible that some firms would never be "first" in the sample period. I want to delete all the observations after the year the firm coded 1 for "first", how can I achieve this?
Here is some data:
Code:
year firm first 2010 0035 0 2011 0035 0 2012 0035 0 2013 0035 0 2014 0035 1 2015 0035 0 2016 0035 0 2017 0035 0 2018 0035 0 2019 0035 0 2013 0042 1 2014 0042 0 2015 0042 0 2016 0042 0 2017 0042 0 2018 0042 0 2019 0042 0 2010 0050 0 2011 0050 0 2012 0050 0 2013 0050 0 2014 0050 0 2015 0050 0 2016 0050 0 2017 0050 0 2018 0050 0 2019 0050 0
Code:
year firm first 2010 0035 0 2011 0035 0 2012 0035 0 2013 0035 0 2014 0035 1 2013 0042 1 2010 0050 0 2011 0050 0 2012 0050 0 2013 0050 0 2014 0050 0 2015 0050 0 2016 0050 0 2017 0050 0 2018 0050 0 2019 0050 0
Comment