I tried to load two files, make some changes, and save them in one go. However I just could not get it right.
Appreciated it in advance if anyone could point me the correct way.
Code:
global ylist "insurance mutual pension"
foreach file of local "emerging" "advanced" {
import delimited `file'.csv, varnames(1) case(upper) clear
encode COUNTRYNAME, gen(COUNTRY)
drop COUNTRYNAME
rename *, lower
foreach var of global $ylist {
rename `var' `var'_`file'
}
xtset country year
save `file', replace
}
0 Response to saving two files using foreach
Post a Comment