1

Is there a way to convert a number of dta files to tab separated files at once, without loading each data set into Stata?

Something like :

x<- get *.dta filenames from directory
foreach file_with_filename in x
     convert to tab separated file 

Apparently the outsheet function can be only used by referring to the dataset (or variable names) currently loaded in memory.

Thanks.

4

1 回答 1

2

像这样的东西。这fs是您需要安装的便捷命令,但只需安装一次。

clear 
ssc inst fs, replace
fs *.dta 

foreach f in `r(files)' {
    use "`f'" 
    local newname : subinstr local f ".dta" ".txt" 
    outsheet using `newname'
}

请注意,这outsheet是一个命令,而不是一个函数。

(编辑删除强制逗号分隔;问题是关于制表符分隔)

于 2013-03-25T17:08:18.397 回答