IDEAS home Printed from https://ideas.repec.org/p/boc/usug02/14.html
   My bibliography  Save this paper

How to face lists with fortitude

Author

Listed:
  • Nicholas J. Cox

    (University of Durham)

Abstract

Among various structures in Stata for cycling through lists (whether lists of variable names, numbers, or arbitrary strings) are foreach and forvalues, introduced in Stata 7 in 2001, and for, introduced in Stata 3.1 in 1992, and revised in 5.0 (1997) and 6.0 (1999). Typically, each member of the list supplied is substituted in turn in one or more commands within the structure being used. This is a tutorial specifically designed for Stata users who do little or no Stata programming. Despite being labelled as programming commands, these structures have many uses either interactively or within do files and help impart both speed and system to repetitive tasks. One prerequisite for understanding foreach and forvalues is the idea of a local macro, of which the most difficult part is understanding the strange name. With that idea assimilated, it is relatively easy to see how foreach and forvalues can be used in a large variety of problems. Despite being newer than for in Stata, these structures are recommended over for to new users, or to more experienced users who have made little or no use of any of these to date. For completeness, there is also comparison with for, and some comments on their relative merits.

Suggested Citation

  • Nicholas J. Cox, 2002. "How to face lists with fortitude," United Kingdom Stata Users' Group Meetings 2002 14, Stata Users Group.
  • Handle: RePEc:boc:usug02:14
    as

    Download full text from publisher

    File URL: http://fmwww.bc.edu/RePEc/usug2002/fortitude.pdf
    Download Restriction: no
    ---><---

    Citations

    Citations are extracted by the CitEc Project, subscribe to its RSS feed for this item.
    as


    Cited by:

    1. Nicholas J. Cox, 2012. "Speaking Stata: Output to order," Stata Journal, StataCorp LP, vol. 12(1), pages 147-158, March.
    2. Nicholas J. Cox, 2008. "Stata tip 59: Plotting on any transformed scale," Stata Journal, StataCorp LP, vol. 8(1), pages 142-145, February.

    More about this item

    Statistics

    Access and download statistics

    Corrections

    All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:boc:usug02:14. See general information about how to correct material in RePEc.

    If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

    We have no bibliographic references for this item. You can help adding them by using this form .

    If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.

    For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: Christopher F Baum (email available below). General contact details of provider: https://edirc.repec.org/data/stataea.html .

    Please note that corrections may take a couple of weeks to filter through the various RePEc services.

    IDEAS is a RePEc service. RePEc uses bibliographic data supplied by the respective publishers.