【问题标题】:Stata command line arguments in batch mode批处理模式下的 Stata 命令行参数
【发布时间】:2013-06-22 18:16:39
【问题描述】:

helpful FAQ from Stata 描述了可以将参数传递给do 文件。我的do 文件如下所示:

* program.do : Program to fetch information from main dataset
args inname outname

save `outname', emptyok // file to hold results
insheet using `inname', comma clear names case

// a bunch of processing

save `outname', replace

根据常见问题解答,此脚本可以使用do filename.csv result.dta 运行。当我从 Stata 中运行此命令时,一切正常。但是,该程序很长,因此我想以批处理模式运行它。 Stata 有another FAQ 关于批处理模式。

结合这些网页的信息,我在 Unix 提示符下键入以下内容:

$ nohup stata -b do program.do filename.csv result.dta &

Stata 启动,但因以下错误而终止:

. save `outname', emptyok // file to hold results
invalid file specification
r(198);

一个小实验告诉我,当我以批处理模式运行程序时,Stata 永远不会接收到这两个参数。这个问题的解决方案是什么? (即在批处理模式下运行时如何将参数传递给 do 文件?)

【问题讨论】:

  • 看来你不能这样做。

标签: arguments batch-processing stata


【解决方案1】:

下面的帖子可能会有所帮助:

http://www.stata.com/statalist/archive/2012-09/msg00609.html

在 Windows 中,如果我的程序 Test.do 是:

args a b
display "`a'" 
display "`b'" 

我可以在 Windows 中以批处理模式运行它,只需键入:

"c:\Stata13\stata.exe" /e do "c:\Scripts\Test.do" Test Script

它会显示(在Stata中):

Test

Script

所以我想知道nohup 是否是阻止您的程序运行的原因。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 2018-05-21
    • 2010-11-20
    • 2016-05-11
    • 2018-11-07
    相关资源
    最近更新 更多