
From  Jeff Rosen <rosen.53@osu.edu> 
To  statalist@hsphsun2.harvard.edu 
Subject  RE: st: RE: Replacing Missing Values for multiple variables at one time? 
Date  Tue, 11 Jul 2006 07:32:43 0400 
You can loop using while, forvalues or foreach.
All these constructs resemble standard constructs in most other programming
languages. The canonical source is [P]. The main need is
really to understand how to use local macros to control looping
in detail.
On forvalues and foreach,
. search forvalues
would point you to various material, including
FAQ . . . . . . . . . . . . . . . . Looping over parallel lists in Stata 8
12/04 How do I process parallel lists in Stata 8?
http://www.stata.com/support/faqs/lang/parallel.html
FAQ . . . . . . . . . . Going through groups in order of first occurrence
9/05 How do I go through the groups of a variable in
order of their first occurrence in the dataset?
http://www.stata.com/support/faqs/data/groupsinseq.html
FAQ . . . . . . . . . . Making foreach go through all values of a variable
8/05 Is there a way to tell Stata to try all values of a
particular variable in a foreach statement without
specifying them?
http://www.stata.com/support/faqs/data/foreach.html
FAQ . . . . . . . . . Counting distinct strings across a set of variables
7/04 How do I count the number of distinct strings
across a set of variables?
http://www.stata.com/support/faqs/data/distinctstrings.html
SJ32 pr0009 . . . . . . . . . . . . . Speaking Stata: Problems with lists
Q2/03 SJ 3(2):185202 (no commands)
discusses ways of working through lists held in macros
SJ22 pr0005 . . . . . . Speaking Stata: How to face lists with fortitude
Q2/02 SJ 2(2):202222 (no commands)
demonstrates the usefulness of for, foreach, forvalues, and
local macros for interactive (non programming) tasks
The last two may be closest to what you need. A Google on "how to face lists
with fortitude" will find internet sources of a shortened version of
SJ 2(2): 202222 (2002), the numerology of which is purely fortuitous.
Nick
n.j.cox@durham.ac.uk
Jeff Rosen
> Is there a tutorial out there that shows how loops are coded in Stata?
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
* * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/
© Copyright 1996–2021 StataCorp LLC  Terms of use  Privacy  Contact us  What's new  Site index 