Dear Clyde,
Thank you very much.
Sorry for the error, it was meant to be a zero.
Thanks again!
Regards!
Thank you very much.
Sorry for the error, it was meant to be a zero.
Thanks again!
Regards!
bys reg: egen stdr = sd(meanrain) replace stdr = 2*stdr
year | month | reg | mean | rainfall | sd | normrain |
1983 | 10 | 1 | 18.43741 | 14.465 | 6.891529 | 1 |
1983 | 11 | 1 | 20.09833 | . | 6.891529 | 0 |
1983 | 12 | 1 | 26.05887 | . | 6.891529 | 0 |
1984 | 1 | 1 | 16.82793 | . | 6.891529 | 0 |
1984 | 2 | 1 | 9.908793 | 6.62 | 6.891529 | 1 |
1984 | 3 | 1 | 7.752069 | 4.79 | 6.891529 | 1 |
sum rainfall gen byte normal_rainfall = inrange(rainfall, r(mean)-r(sd), r(mean)+r(sd)) if !missing(rainfall)
region | year | month | drought |
1 | 2005 | 1 | 0 |
1 | 2005 | 2 | 0 |
1 | 2005 | 3 | 0 |
1 | 2005 | 4 | 0 |
1 | 2005 | 5 | 0 |
1 | 2005 | 6 | 1 |
1 | 2005 | 7 | 1 |
1 | 2005 | 8 | 0 |
1 | 2005 | 9 | 0 |
1 | 2005 | 10 | 0 |
1 | 2005 | 11 | 1 |
1 | 2005 | 12 | 0 |
gen drought2 =0
replace drought2==1 if drought =1 & month=1 & month=2
replace drought2==1 if drought =1 & month=1 & month=2
* Example generated by -dataex-. To install: ssc install dataex clear input int year byte month float(reg drought) 2005 1 1 0 2005 2 1 0 2005 3 1 0 2005 4 1 0 2005 5 1 0 2005 6 1 1 2005 7 1 1 2005 8 1 0 2005 9 1 0 2005 10 1 0 2005 11 1 1 2005 12 1 0 2006 1 1 0 2006 2 1 0 2006 3 1 0 2006 4 1 1 2006 5 1 1 2006 6 1 0 2006 7 1 0 2006 8 1 0 2006 9 1 1 2006 10 1 1 2006 11 1 0 2006 12 1 0 end
// CREATE A MONTHLY DATE VARIABLE gen mdate = ym(year, month) format mdate %tm assert missing(mdate) == missing(year, month) // IDENTIFY SPELLS OF DROUGHT sort mdate gen spell = sum(drought == 1 & drought[_n-1] != 1) replace spell = 0 if !drought by spell (mdate), sort: gen duration = _N if drought by spell (mdate): gen byte two_consec_months = (duration >= 2) & !missing(duration) sort mdate
Comment