I have the firms treated in different years. I want to create a column that has the year of treatment as the value for all years for that firm. This is the example dataset:
I want a treat_timing variable which has value 0 for firm 1, 2020 for Firm 2, 2021 for Firm 3 and so on. Is there a way I can do it without generating a zero variable and replacing with treatment year value for each firm?
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float firmid byte treat int year 1 0 2016 1 0 2017 1 0 2018 1 0 2019 1 0 2020 1 0 2021 1 0 2022 2 0 2016 2 0 2017 2 0 2018 2 0 2019 2 1 2020 2 1 2021 2 1 2022 3 0 2016 3 0 2017 3 0 2018 3 0 2019 3 0 2020 3 1 2021 4 0 2016 4 0 2017 4 0 2018 4 0 2019 4 0 2020 4 0 2021 4 0 2022 5 0 2016 5 0 2017 5 0 2018 5 0 2019 5 1 2020 5 1 2021 5 1 2022 end
Comment