Dear All

I have created a loop to generate forecasts using a lasso regressions that (I hope) are considered out of sample.

Can anyone please confirm if these forecasts are out of sample in the sense that these simple lines of the code will only use observations up to the year 1996 to train the model and subsequently generate forecasts for the period after 1996 that are out of sample? Do I have to condition "predict" on sample 2 ?!
The model is estimated using lasso regression from Stata 16

My code is:

Code:
gen sample=.
replace sample=1 if year<1996  // training sample
replace sample=2  if sample==.   // evaluation sample

quietly lasso linear BUS s1 s2 s3 s4 s5 if sample == 1
estimates store lasso

estimate restore lasso
predict BUShat, postselection. // out of sample forecasts