首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从命令行确定Stata文件的ds_format?

如何从命令行确定Stata文件的ds_format?
EN

Stack Overflow用户
提问于 2013-01-02 20:36:54
回答 1查看 161关注 0票数 4

我把这个Perl一行放在一起来确定一些文件的Stata "ds_format“.

for file in *.dta; do perl -MParse::Stata::DtaReader -e 'open my $fileHandle, "<", @ARGV; my $dta = new Parse::Stata::DtaReader($fileHandle); print "$ARGV[0] is in STATA ds_format " . $dta->{ds_format} ,"\n\n";' $file; done

..。但是我假设有一种方法可以使用命令行stata命令来获取相同的信息。在那里吗?上面的脚本打印我的文件:

study1a.dta在STATA ds_format 113 study1b.dta在斯塔塔ds_format 115号 研究2.dta在STATA ds_format 115中

另请参阅:

  • 113
  • http://www.stata.com/help.cgi?dta
  • http://search.cpan.org/dist/Parse-Stata-DtaReader/
  • http://stat.ethz.ch/R-manual/R-devel/library/foreign/html/read.dta.html
EN

回答 1

Stack Overflow用户

发布于 2015-01-20 16:11:14

现在,您只需读取文件的第一个字符即可确定版本。除了版本文件格式版本117 ( Stata 13的当前版本)之外,版本将存储在XML中,因此必须对此方法进行增强。

代码语言:javascript
复制
file open fhandle using dataset.dta, read binary
file read  fhandle %1s firstbytechar
file close fhandle
if "`firstbytechar'"=="<"{
    di "Version 117"
}
else {
    mata: st_numscalar("v", ascii("`firstbytechar'"))
    di "Version " v
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14158156

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档