Hello all,
I have filenames 1992Germany 1996Germany 1992Korea 1996Korea (I have years 1992, 1996,1997,2001,2002,2006 and about 9 countries)
I wanted to loop through these different files and was struggling how to do it. Also for each file, I will be creating a new variable. For instance for 1992Germany, I will create a variable TradeGermany1992; for 1996Germany , I will create TradeGermany1992 and so on.
I tried:
local year 1992 1996 1997 2001 2002 2006
local country Germany Korea
foreach y local year{
for each c local country{
use `year'`country'.dta
gen trade`country'`i'=trade*value
save new`year'`country'.dta,replace
}
}
But it doesn't run. Can you please give me ideas and how to loop those files. Thanks in advance.
I have filenames 1992Germany 1996Germany 1992Korea 1996Korea (I have years 1992, 1996,1997,2001,2002,2006 and about 9 countries)
I wanted to loop through these different files and was struggling how to do it. Also for each file, I will be creating a new variable. For instance for 1992Germany, I will create a variable TradeGermany1992; for 1996Germany , I will create TradeGermany1992 and so on.
I tried:
local year 1992 1996 1997 2001 2002 2006
local country Germany Korea
foreach y local year{
for each c local country{
use `year'`country'.dta
gen trade`country'`i'=trade*value
save new`year'`country'.dta,replace
}
}
But it doesn't run. Can you please give me ideas and how to loop those files. Thanks in advance.
Comment