以批处理模式启动 Stata 时更改 profile.do

Change profile.do while starting Stata in batch mode

是否可以使用不同的 profile.do 文件启动 Stata?是否有命令行选项来设置它?

例如,我有一个 profile.do 用于生产性工作,我想使用另一个 profile.do 来测试一些东西或初始化一些其他东西。

我不是真正的 Stata user/developer,但我创建了一个基于 Java 的加载项,需要先对其进行初始化。在启动时切换到更改 profile.do 将有助于设置一个开发环境来初始化未完成的加载项。

很遗憾,不能提供文件名作为参数。

尽管如此,假设您的计算机上保存了一些 profile.do 个文件:

profile1.do
profile2.do
profile3.do

与其将这些文件中的相关命令复制到主 do 文件中,不如在 do 文件中简单地使用 include 命令来完成您想要的操作 主 do 文件。这将允许您根据需要 运行 您的偏好 profile.do 文件这些被存储。

main.do 文件的玩具示例如下:

include profile2.do
sysuse auto, clear
regress price mpg weight

正如include的帮助文件所指出的,这种方法的优点是:

"...any local macros (changed settings, etc.) created by executing the file are not dropped or reset when execution of the file concludes..."

通过这种方式,您可以 运行 以干净灵活的方式使用不同的 do 文件 差异首选项文件,全部采用批处理模式:

stata -b do main

自然输入 help include 将提供更多信息。