Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: Replacing Missing Values for multiple variables at one time?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: Replacing Missing Values for multiple variables at one time?
Date   Tue, 11 Jul 2006 11:00:36 +0100

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

SJ-3-2  pr0009  . . . . . . . . . . . . . Speaking Stata:  Problems with lists
        Q2/03   SJ 3(2):185--202                                 (no commands)
        discusses ways of working through lists held in macros

SJ-2-2  pr0005  . . . . . .  Speaking Stata:  How to face lists with fortitude
        Q2/02   SJ 2(2):202--222                                 (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): 202-222 (2002), the numerology of which is purely fortuitous. 

Nick 
[email protected] 

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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index