Good Morning,
I want to import in STATA (and save as .dta with the prefix "geo_") several .txt files, all contained in a directory. Therefore, I've written this loop:
cd "C:\Users\MyLocalDirectory\"
local myfilelist : dir . files "*.txt"
foreach file of local myfilelist {
insheet using `file'
save "geo_`file'$out_suffix", replace
}
However, in this way the files are saved in .txt format and not .dta. If I remove "$out_suffix", and write "geo_`file'.dta, I obtain a .dta file but its name is "geo_`file'.txt.dta". It is not what I need. I need "geo_`file'.dta".
Many thanks in advance for any suggestions.
Best,
Alessandro Giovannini
___________________________________
CEPS Associate Researcher - Economic Policy Unit
CEPS - Centre for European Policy Studies
I want to import in STATA (and save as .dta with the prefix "geo_") several .txt files, all contained in a directory. Therefore, I've written this loop:
cd "C:\Users\MyLocalDirectory\"
local myfilelist : dir . files "*.txt"
foreach file of local myfilelist {
insheet using `file'
save "geo_`file'$out_suffix", replace
}
However, in this way the files are saved in .txt format and not .dta. If I remove "$out_suffix", and write "geo_`file'.dta, I obtain a .dta file but its name is "geo_`file'.txt.dta". It is not what I need. I need "geo_`file'.dta".
Many thanks in advance for any suggestions.
Best,
Alessandro Giovannini
___________________________________
CEPS Associate Researcher - Economic Policy Unit
CEPS - Centre for European Policy Studies
Comment