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

}

1 Answer 1

1

The filenames are specified incorrectly. Instead, try this:

use `"`filename'.dta"'
use `"`filename'Prices.dta"'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.