0

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

}
Community
  • 1
  • 1
phdstudent
  • 1,060
  • 20
  • 41

1 Answers1

1

The filenames are specified incorrectly. Instead, try this:

use `"`filename'.dta"'
use `"`filename'Prices.dta"'