Hi I am working with a panel data set for 300 districts from 1959 to 1999 using Stata 13. I have got mean, minimum and maximum daily temperature data. Example is given below

I am trying to identify the days on which the daily maximum temperature of a district in the given period exceeds its 90th percentile centred on a 5-day window for the base period (in my case 1959 to 1999). Specifically, I need to generate a variable which takes the value 1 if the maximum temperature exceeds the 90th percentile centred on a 5-day window and 0 otherwise.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(DT MT YEAR) double(LAT LON) float(MEANT MINT MAXT id)
1 1 1969 7.5 94.5  25.2 20.32 30.08  1
1 1 1970 7.5 94.5  27.7 25.42 29.97  2
1 1 1971 7.5 94.5 26.72 24.26 29.18  3
1 1 1972 7.5 94.5 25.39 21.73 29.05  4
1 1 1973 7.5 94.5 27.63 24.88 30.38  5
1 1 1974 7.5 94.5 26.39 24.41 28.38  6
1 1 1975 7.5 94.5 26.74 23.62 29.86  7
1 1 1978 7.5 94.5 27.17 23.86 30.48  8
1 1 1980 7.5 94.5 26.98 23.75  30.2  9
1 1 1981 7.5 94.5  26.1 22.04 30.15 10
1 1 1982 7.5 94.5 26.98 24.41 29.55 11
1 1 1983 7.5 94.5 25.73 21.64 29.81 12
1 1 1988 7.5 94.5 25.88 22.01 29.76 13
1 1 1989 7.5 94.5 27.24 23.92 30.55 14
1 2 1969 7.5 94.5 25.27 20.83 29.71 15
end
(I had a similar issue some time ago and received very helpful suggestions (https://www.statalist.org/forums/for...nuous-sequence), however I am not sure how to modify the code to incorporate the 90th percentile centered on a 5-day window!)

Any suggestion will be appreciated