Hello again statalist
My data are panel data with firm and year variables, I have an indicator variable, breach_event, it equals 1 if the firm breaches a covenant in a year, and 0 otherwise. I want to create another indicator variable, breach, that equals 1 if the firm has a data breach event during the sample period 2014-2020, and 0 otherwise. e.g. frim A has breach_event==1 in 2017, then all the years (2014-2020) should have breach==1.
How can I achieve this? Thanks!
Edit:
The code I tried is the following, it only gets breach==1 for the year of and the years after the breach event, but not years before that. How it can be revised?
My data are panel data with firm and year variables, I have an indicator variable, breach_event, it equals 1 if the firm breaches a covenant in a year, and 0 otherwise. I want to create another indicator variable, breach, that equals 1 if the firm has a data breach event during the sample period 2014-2020, and 0 otherwise. e.g. frim A has breach_event==1 in 2017, then all the years (2014-2020) should have breach==1.
How can I achieve this? Thanks!
Edit:
The code I tried is the following, it only gets breach==1 for the year of and the years after the breach event, but not years before that. How it can be revised?
Code:
by firm(year), sort: gen breach = min(sum(breach_event == 1), 1)
Comment