rangestat has been upgraded since #11 was posted and now includes a (reg) statistic. If I understand what you are asking and shooting blind since I cannot see your data or the code you tried, the following will calculate a regression using a 12 month window only for observations that are in June.

and the results for the spot check:

Code:

* create panel of monthly stocks returns over 30 years clear set seed 312312 set obs 1000 gen long stockid = _n expand 360 bysort stockid: gen mdate = ym(1986,12) + _n format %tm mdate gen ret = runiform() gen mret = runiform() * define a valid upper interval bound only when the month is june gen high = cond(month(dofm(mdate)) == 6, mdate, -999) * regress over a 12 month window rangestat (reg) ret mret, by(stockid) interval(mdate -11 high) * spot check results list if stockid == 2 & mdate == ym(2001,6) reg ret mret if stockid == 2 & inrange(mdate, ym(2000,7), ym(2001,6))

Code:

. list if stockid == 2 & mdate == ym(2001,6) +---------------------------------------------------------------------------------+ 534. | stockid | mdate | ret | mret | high | reg_nobs | reg_r2 | reg_adj~2 | | 2 | 2001m6 | .7165378 | .6462917 | 497 | 12 | .1522346 | .06745806 | |---------------------------------------------------------------------------------| | b_mret | b_cons | se_mret | se_cons | | .31540325 | .37679786 | .23536795 | .16262095 | +---------------------------------------------------------------------------------+ . reg ret mret if stockid == 2 & inrange(mdate, ym(2000,7), ym(2001,6)) Source | SS df MS Number of obs = 12 -------------+---------------------------------- F(1, 10) = 1.80 Model | .097820681 1 .097820681 Prob > F = 0.2099 Residual | .544744687 10 .054474469 R-squared = 0.1522 -------------+---------------------------------- Adj R-squared = 0.0675 Total | .642565368 11 .058415033 Root MSE = .2334 ------------------------------------------------------------------------------ ret | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- mret | .3154033 .235368 1.34 0.210 -.2090292 .8398357 _cons | .3767979 .1626209 2.32 0.043 .0144558 .7391399 ------------------------------------------------------------------------------

## Comment