A shortcut through long loops: An illustration of two alternatives to looping over observations
Ward Vanlaar
Additional contact information
Ward Vanlaar: Traffic Injury Research Foundation, Ottawa
Stata Journal, 2008, vol. 8, issue 4, 540-553
Abstract:
It is well known that looping over observations can be slow and should be avoided. The objective of this article is to discuss two alternative solutions to looping over observations that can be used to overcome a particular data-management problem of merging datasets in which unique key identifiers changed over time. The first alternative, mapch, which is introduced in this article, uses a combination of appending, indexing, and merging to solve the problem, while the second alternative uses repeated merging. Both solutions are much quicker than looping over observations. However, depending on the nature of the problem, one solution may work better than the other. It is argued that the use of such dataset-type manipulations may be suitable to overcome other data-management problems. More generally speaking, the issue that is addressed—searching for an alternative to looping over observations—may be common and illustrates the importance of balancing the costs of developing an efficient solution with the benefits accruing from that solution. Copyright 2008 by StataCorp LP.
Keywords: mapch; appending; data management; indexing; looping; merging (search for similar items in EconPapers)
Date: 2008
References: Add references at CitEc
Citations:
Downloads: (external link)
http://www.stata-journal.com/article.html?article=dm0041
http://www.stata-journal.com/software/sj8-4/dm0041/ (text/html)
Related works:
This item may be available elsewhere in EconPapers: Search for items with the same title.
Export reference: BibTeX
RIS (EndNote, ProCite, RefMan)
HTML/Text
Persistent link: https://EconPapers.repec.org/RePEc:tsj:stataj:v:8:y:2008:i:4:p:540-553
Ordering information: This journal article can be ordered from
http://www.stata-journal.com/subscription.html
Access Statistics for this article
Stata Journal is currently edited by Nicholas J. Cox and Stephen P. Jenkins
More articles in Stata Journal from StataCorp LLC
Bibliographic data for series maintained by Christopher F. Baum () and Lisa Gilmore ().