I want to create six different categorical variables that capture a treatment of varying intensities and time lags (I just mention one of them here). The way I want to create them are as follows:
Min_13 = 1 if Treat_t-1 > 25 & Treat_t-1 <49 | Treat_t-2 > 25 & Treat_t-2 <49 | Treat_t-3 > 25 & Treat_t-3 <49
replace Min_13 = 0, if missing (Min_13)
How can I run a loop to do this?
Here's a code chunk that I try, but I do not think it is right ---->
by fips year, sort: gen Surface_Min_t1_3 = cond(max(Hurr_Surface1, Hurr_Surface2, Hurr_Surface3)>25 & max(Hurr_Surface1, Hurr_Surface2, Hurr_Surface3)<49,1,0) // Any hurricane that causes windspeeds >50kts & < 96kts
Min_13 = 1 if Treat_t-1 > 25 & Treat_t-1 <49 | Treat_t-2 > 25 & Treat_t-2 <49 | Treat_t-3 > 25 & Treat_t-3 <49
replace Min_13 = 0, if missing (Min_13)
How can I run a loop to do this?
Here's a code chunk that I try, but I do not think it is right ---->
by fips year, sort: gen Surface_Min_t1_3 = cond(max(Hurr_Surface1, Hurr_Surface2, Hurr_Surface3)>25 & max(Hurr_Surface1, Hurr_Surface2, Hurr_Surface3)<49,1,0) // Any hurricane that causes windspeeds >50kts & < 96kts
Comment