Hello everyone, I am new to Stata and woud like your help. I have a sample of size 249, and I would like to run a regression over the first 50 observations. The only way I know is to create a sequence variable and use "if", and it works (the blue line). I was wondering if I can use "in" instead? (the red line)
When I run the following code, I got an error message "'50-start_T+1' invalid observation number"


clear all

import excel "data/xyz.xlsx", firstrow case(lower) clear

egen t1 = seq()

tsset t1
sca n1 = 65
sca start_T = 50

gen b_cons = .
gen b_x1 = .
gen b_x2 = .
gen y_f = .

forvalues i = `=start_T'/`=_N-n1' {
//reg y x1 x2 if t1<= `i' & t1> `i'-start_T // it works
reg y x1 x2 in `i'-start_T+1/`i' // it does not work; error
predict temp in `i+n1'
replace y_f = temp in `i+n1'
drop temp
}



I would like to know how to do it because "if" does not extend to more advanced models, but I hope "in" can.