如何在Stata中运行另一个ado文件中的ado文件?

发布于 2024-11-27 07:18:15 字数 113 浏览 2 评论 0原文

运行另一个 R 脚本

source("script.R")

在 R 中,我可以使用How can I do the same in Stata?

In R, I can run another R script using

source("script.R")

How can I do the same in Stata?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

靑春怀旧 2024-12-04 07:18:15

在 Stata 中,有两种类型的脚本:

  1. do 文件,它们是您键入命令时的命令序列,其中可能包含几乎任何内容,
    还有
  2. ado 文件,它们是独立的程序脚本。 Ado 代表“自动加载 DO 文件”。

主要区别在于,要执行 do 文件,您需要 do 它或 run 它:

do whatever.do

显示输出,并

run whatever.do

抑制输出。

自动加载的do-files,顾名思义,是自动加载的。当您输入

blah blah1 blah2

Stata 时,它首先会在内存中查找程序 blah。如果不存在,它将在其 adopath 中标识的子目录中查找文件 blah.ado,默认情况下包括 Stata 自己的目录以及当前目录(如果您有兴趣,请输入 adopath 以了解更多信息)。如果它找到这个 blah.ado,它会 (1) 确保其中有 program Define blah,并且 (2) 尝试使用您指定的任何参数执行该程序提供(blah1 blah2)。如果它无法在任何地方找到文件 blah.ado,它将发出错误消息:

   . blah blah1 blah2
   unrecognized command:  blah
   r(199);

In Stata, there are two types of scripts:

  1. There are do-files, which are sequences of the commands as you type them, which may contain pretty much anything,
    and
  2. There are ado-files, which are self-contained program scripts. Ado stands for "Automatically loaded DO files".

The primary distinction is that to execute the do-file, you need to do it or run it:

do whatever.do

shows the output, and

run whatever.do

suppresses the output.

The automatically loaded do-files, as the name implies, are loaded automatically. When you type

blah blah1 blah2

Stata will first look for the program blah in its memory. If it is not there, it will look for file blah.ado in the subdirectories identified in its adopath that by default includes Stata's own directories, as well as the current directory (type adopath to find out more, if you are interested). If it finds this blah.ado, it will (1) make sure it has program define blah inside it, and (2) try to execute this program with whatever arguments you supplied (blah1 blah2). If it fails to find the file blah.ado anywhere, it will issue an error message:

   . blah blah1 blah2
   unrecognized command:  blah
   r(199);
没有心的人 2024-12-04 07:18:15

Stata 将在默认目录中搜索 ado 文件,如顶部答案所示。要查看系统默认目录,请键入:

。 sysdir

您可以手动将 ado 文件的目录(例如,个人路径)更改为您喜欢的文件夹,使用:

。 sysdir 设置个人“C:\your-ado-folder”

信用:https://kb .iu.edu/d/arur

Stata will search for the ado file in the default directories as the top answer indicated. To see your system default directories, type:

. sysdir

You can manually change the directory (e.g., the PERSONAL path) for ado files to the folder you like, using:

. sysdir set PERSONAL "C:\your-ado-folder"

Credit: https://kb.iu.edu/d/arur

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文