In #5, The outfile encountred incremental increase of observation everytime i ran the command. So, I made few modifications and I think works also fine.
clear all
tempfile tempdata
save `tempdata', emptyok
foreach table in Aliho Comm Deng Ting {
clear
odbc load, dsn(dsnname) table("`table'$") lowercase clear
*your code for cleanup
gen source = `"`table'"'
append using `tempdata'
save `"`tempdata'"', replace
}
clear all
tempfile tempdata
save `tempdata', emptyok
foreach table in Aliho Comm Deng Ting {
clear
odbc load, dsn(dsnname) table("`table'$") lowercase clear
*your code for cleanup
gen source = `"`table'"'
append using `tempdata'
save `"`tempdata'"', replace
}

Comment