Hi!
I am working on survey data and want to export the survey year for each country to an excel list.
I used this code:

foreach x of num 1/51 {
tab year if country == `x'
putexcel B`x' = year
}

However, it exports the same year for all countries .

I want to use outexcel, as I already exported other data to that list.

Thank you for your help!