Dear All,

I have created a toy example for my question

Code:
set obs 5

gen x1 = 1
gen x2 = 1
gen y1 = 1
gen y2 = 1



forvalues t = 1(1)2 {

    foreach var of varlist x y {
    
    sum `var'`t'
    
    }



}
When I run the loops, I got the error message "x ambiguous abbreviation". It seems like the sum command ignores the `t' part. Can anyone help?

P.S, I need the t loop because in the real problem, I have to read the dataset that are named based by years.

Thanks!!