I'm trying to write a foreach loop to convert a few hundred text files, divided up into many folders. So far I have this:
foreach f in (listed out folders) {
foreach x in (listed out text files) {
capture import `x' delimited, delimiter(tab)
save `x'.dta, replace
clear
}
}
but I keep getting a "no variables defined" r(111) error. I have a feeling it's about the formatting of the list of folders and files, but I've been struggling to figure out the proper way to do so. I apologize in advance if the code is poorly written. I'm an undergraduate in my first semester of learning Stata.
I didn't want to put the whole lists for the folders and files, because it'd make the post annoying long, but they're listed out in this format:
foreach f in 03312006 03312007 03312008 etc. and
foreach x in CI_03312006.txt ENT_03312006.txt etc.
Thank you.
Related Posts with Writing nested foreach loop to convert many .txt files to .dta
Simple approach to fit a multinomial logit model to panel data?I have a longitudinal dataset with 5 time points (age 18, 26, 32, 38, 45) at which patients had oral…
Coefficient equality test after rifhdregDear all, I would like to perform a coefficient equality test across all five quantiles following r…
Fixed effect estimator, interaction effect with dummy variable varying within unit and timeHei, I am doing a fixed effect model on a panel of N = 1089 and T = 30 000 (ish). ESGscore = beta…
Survival Analysis - Failure / UnknownHi there, I have a question regarding survival data My data is as follows: Code: * Example gener…
Non-linear ARDL bound testHow can I do NARDL in STATA? is there any user written command? FYI: I use STATA 15.1 …
Subscribe to:
Post Comments (Atom)
0 Response to Writing nested foreach loop to convert many .txt files to .dta
Post a Comment