Home  >>  Archives  >>  Volume 2 Number 2  >>  pr0005

The Stata Journal
Volume 2 Number 2: pp. 202-222



Subscribe to the Stata Journal
cover

Speaking Stata: How to face lists with fortitude

Nicholas J. Cox
University of Durham, UK
[email protected]
Abstract.   Three commands in official Stata, foreach, forvalues, and for, provide structures for cycling through lists of values (variable names, numbers, arbitrary text) and repeating commands using members of those lists in turn. All 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.
Terms of use     View this article (PDF)

View all articles by this author: Nicholas J. Cox

View all articles with these keywords: foreach, forvalues, for, lists, local macros, substitution first

Download citation: BibTeX  RIS

Download citation and abstract: BibTeX  RIS