I am trying to loop through a list of filenames in Stata. Filenames are of the type: CityName.dta
, CityNamePrices.dta
, etc.
I tool a look at this similar question but was not able to adapt it to my setup.
Here is the code I have tried:
local mylist Atlanta Boston Charlotte Chicago
foreach filename of local mylist {
use `"`filename'"'.dta
*Do some stuff here
use `"`filename'"'Prices.dta
*Do some more stuff here
clear
}
The filenames are specified incorrectly. Instead, try this:
use `"`filename'.dta"'
use `"`filename'Prices.dta"'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.