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   Jeff Rosen <[email protected]>
To   [email protected]
Subject   RE: st: RE: Replacing Missing Values for multiple variables at one time?
Date   Tue, 11 Jul 2006 07:32:43 -0400

Thanks for the information. I'll look through those sources. Part of my problem as I get involved in Stata is that the coding is slightly different from C++. I keep getting little notations mixed up. For example, on the code that you provided, calling the new variable name needed an accent mark before the word and an apostrophe after. I accidentally used two apostrophes and the do-file failed.

Jeff Rosen

At 06:00 AM 7/11/2006, you wrote:

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/


*
*   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