Hi, I'm using Stata 14 on Windows.
Currently I use this syntax for each country SEPARATELY (here only for Georgia):
use "D:\drive\SME adapt in COVID19\data\merged data\Georgia1.dta"
include 1st_round_vars
keep idstd adapt onlineadapt riseadapt workeradapt
rename * *1
rename idstd1 idstd
save rst_tmp, replace
use "D:\drive\SME adapt in COVID19\data\merged data\Georgia2.dta"
include 2nd_round_vars
keep idstd adapt onlineadapt riseadapt workeradapt
rename * *2
rename idstd2 idstd
merge 1:1 idstd using rst_tmp, keepusing(adapt onlineadapt riseadapt workeradapt) gen(mrg1)
drop mrg1
generate country= "Georgia"
save ctr_merging.dta, replace
BUT, I am new to stata. And I am trying to use looping by through country's data files. The names of the data files are "Georgia1.dta", "Belarus1.dta", "Moldova1.dta", "Mongolia1.dta" etc.
use "D:\drive\SME adapt in COVID19\data\merged data\Georgia2.dta"
instead of this I am trying to use this
cd "C:\Users\user\Desktop\panel\merged data"
local countrylist1 "Belarus1 Estonia1 Georgia1 Kazakhstan1 Latvia1 Lithuania1 Mongolia1 Moldova1 Russia1"
foreach country of local countrylist1 {
local datafiles : dir . files "`country'*.dta"
foreach f of local files {
use `f', replace
}
Any help appreciated.
Related Posts with looping through data files
Panel Data Ordered Logit not able to calculate.Dear Statlisters, Quick question regarding ordered logit. I have a panel dataset from China with in…
Confidence bounds for interquartile rangeDear Statalist members, I would be most thankful for an advice. I need to estimate the confidence in…
Interpret odds ratios log variableDear all, I'm running a similar code as this one: Code: sysuse auto.dta,clear gen domestic=1-fore…
Confidence interval for interquartile rangeDear Statalist members, I would be most thankful for an advice. I need to estimate the confidence in…
Interpreting "estat vce, corr output" posetimation of menbreg with random slopes and interceptHi, I'm looking to get some assistance understanding the output of a postestimation command, estat …
Subscribe to:
Post Comments (Atom)
0 Response to looping through data files
Post a Comment