当前位置: X-MOL 学术Stata J. Promot. Commun. Stat. Stata › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
Speaking Stata: Loops, again and again
The Stata Journal: Promoting communications on statistics and Stata ( IF 3.2 ) Pub Date : 2020-12-22 , DOI: 10.1177/1536867x20976340
Nicholas J. Cox 1
Affiliation  

Two commands in official Stata, foreach and forvalues, provide structures for looping through lists of values (variable names, numbers, arbitrary text) and repeating commands using members of those lists in turn. These commands may be used interactively, and none is restricted to use in Stata programs. They are explained and compared in some detail with a variety of examples. In addition, a self-contained exposition is given on local macros, understanding of which is needed for use of foreach and forvalues.

This column is a revision of the column “How to face lists with fortitude”, which appeared in Stata Journal 2: 202–222 (2002). (The bizarre bibliographical details are too, too extraordinary not to be flagged but were pure happenstance.) The presentation here has been trimmed of now historic content and corrected, improved, and updated in several minor details.



中文翻译:

说话的状态:一次又一次地循环

官方Stata中的两个命令foreachforvalues提供了循环遍历值列表(变量名,数字,任意文本)并依次使用这些列表的成员重复命令的结构。这些命令可以交互使用,并且不限于在Stata程序中使用。通过各种示例对它们进行了详细解释和比较。另外,在局部宏上给出了一个独立的说明,需要了解使用foreachforvalues的地方

本专栏是“ Stata Journal 2:202–222(2002)”中“如何用坚韧面对列表”专栏的修订版。(离奇的书目详细信息也是如此,太特殊了,不能被标记出来,而纯属偶然。)这里的演示文稿已从现在的历史内容中进行了裁剪,并在几个较小的细节中进行了纠正,改进和更新。

更新日期:2020-12-22
down
wechat
bug