Hello
I am using the loop function for some simple merges of 5 datasets.
I did it before and it worked. now to redo it again I faced with" too many variables defined" error. Does anyone help me?
my syntax is:

forvalues loop=2002/2016{

clear

use "\\...................\F`loop'.dta",

gen local z=`loop'-1

merge 1:1 Id using "\\..................\G`z'.dta"

keep if _merge==3

drop _merge

save "\\...........................\Cohort`z'.dta", replace

}