循环遍历stata中的文件列表

Loop through a list of files in stata

我正在尝试遍历 Stata 中的文件名列表。文件名的类型为:CityName.dtaCityNamePrices.dta 等。

我查看了 this 类似的问题,但无法使其适应我的设置。

这是我试过的代码:

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

}

指定的文件名不正确。相反,试试这个:

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