Hello everyone,
I have a dataset covering natural disasters in the US for each county from 1994. I want to create a dummy variable if a certain type of hazard say "Flooding" hit a certain county in a certain year. However, I want to exclude counties which were hit in a certain year if there was a similar hazard in previous 3 years. Just to give an example: if county Talbot gets hit twice in a window of 3 years, I want the dummy to take value of 1 only for the first event, but not for the second. Below an example from my data set.
Thank you in advance!

input str20 state int Year str20 county long fips str26 Hazard byte Quarter
"GEORGIA" 1994 "Randolph" 13243 "Flooding" 3
"GEORGIA" 1994 "Rockdale" 13247 "Flooding" 3
"GEORGIA" 1994 "Schley" 13249 "Flooding" 3
"GEORGIA" 1998 "Seminole" 13253 "Flooding" 1
"GEORGIA" 1994 "Spalding" 13255 "Flooding" 3
"GEORGIA" 1998 "Spalding" 13255 "Flooding" 1
"GEORGIA" 2004 "Spalding" 13255 "Flooding" 3
"GEORGIA" 2004 "Stephens" 13257 "Flooding" 3
"GEORGIA" 2009 "Stephens" 13257 "Flooding" 3
"GEORGIA" 1994 "Stewart" 13259 "Flooding" 3
"GEORGIA" 1994 "Sumter" 13261 "Flooding" 3
"GEORGIA" 1998 "Sumter" 13261 "Flooding" 1
"GEORGIA" 1994 "Talbot" 13263 "Flooding" 3
"GEORGIA" 1998 "Talbot" 13263 "Flooding" 1
"GEORGIA" 1994 "Taylor" 13269 "Flooding" 3
"GEORGIA" 1998 "Telfair" 13271 "Flooding" 1
"GEORGIA" 2004 "Telfair" 13271 "Flooding" 3
"GEORGIA" 2009 "Telfair" 13271 "Flooding" 2
"GEORGIA" 1994 "Terrell" 13273 "Flooding" 3
"GEORGIA" 1998 "Terrell" 13273 "Flooding" 1
"GEORGIA" 1994 "Thomas" 13275 "Flooding" 4
"GEORGIA" 1998 "Thomas" 13275 "Flooding" 1
"GEORGIA" 1994 "Tift" 13277 "Flooding" 4
"GEORGIA" 2004 "Toombs" 13279 "Flooding" 3
"GEORGIA" 2009 "Toombs" 13279 "Flooding" 2
"GEORGIA" 2004 "Towns" 13281 "Flooding" 3
"GEORGIA" 1998 "Treutlen" 13283 "Flooding" 1
"GEORGIA" 2004 "Treutlen" 13283 "Flooding" 3
"GEORGIA" 1994 "Troup" 13285 "Flooding" 3
"GEORGIA" 2015 "Troup" 13285 "Flooding" 4
"GEORGIA" 1994 "Twiggs" 13289 "Flooding" 3