Hello,
I would like to confirm whether I generate a variable in a proper way. The definition is as follows:
​​​​​​DISP=forecast dispersion measured as the standard deviation of stock price-deflated analyst forecasts issued within 90 days before earnings announcements.

My code:
sort gvkey fiscal_year fiscal_month
by gvkey fiscal_year: gen mean_forecast = mean(value)
gen DISP = (value-mean_forecast)/prcc_f


Should I/ how do I category the ones issued within 90 days before earnings announcements?

Thank you