|
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: Re: st: Creating a new variable with information from other observations
From |
n j cox <[email protected]> |
To |
[email protected] |
Subject |
Re: Re: st: Creating a new variable with information from other observations |
Date |
Mon, 19 May 2008 15:21:28 +0100 |
.
Your question is an FAQ:
FAQ . . . . . . . . . . Making foreach go through all values of a
variable
4/03 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
Note that -search foreach- would have pointed you to this FAQ.
Nick
[email protected]
Davide Cantoni
Wonderful, that is just what I was looking for. Thank you, Maarten and Even.
Even Bergseng
> Can -levelsof- help you?
Davide Cantoni
>>:: is there a way to run a "foreach" over all (numeric) values that a
>>given variable takes, without having to specify exactly the values
>>that this variable takes? Ok, I see, in most cases this would be a job
>>for "by(sort)", but I cannot help thinking that there are some cases
>>in which bysort does not help me -- for example when I want to run
>>more than one command, as I would do within the braces of
>>"foreach...", or when the units the loop runs over (the `X' in
>>"foreach X", so to speak) are used in some logical condition.
>>
>>In brief: is there a way to create a numlist from the unique values
>>that a variable takes? Or how would you proceed?
*
* 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/