Hi, I have a sample (in long format) of 52 funds (id 1-52) with monthly returns (return), i also have market returns (market) and a time-variable (time from 2007m01 to 2016m12). I have managed to tell Stata that Im working with panel data with the command:
Code:
 xtset id time
.

What i want to do is separate regressions for each id en two separate time periods, from 2007m1 to 2011m12 and from 2012m01 to 2016m12.


Im thinking about two loops that intuitively looks something like this:

Code:
foreach id & time<2012m01

xtreg return market
and

Code:
foreach id & time>2011m12

xtreg return market
I would be very thankfull if someone could help me out here.



Olle