Statalist


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

RE: st: Loop over all unique values of a variable


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Loop over all unique values of a variable
Date   Thu, 14 Feb 2008 13:14:17 -0000

Quite so. -levels- was introduced as an official command during the
lifetime of Stata 8, and so was not documented in the Stata 8 manuals.
In Stata 9, 
-levelsof- was introduced and put out in front, although -levels-
continues to work, as is true in Stata 10. The two are thus different
names for the same command in Stata 9 and 10. 

For the future, note this advice in the FAQ: "The current version of
Stata is 10. Please specify if you are using an earlier version;
otherwise, the answer to your question is likely to refer to commands or
features unavailable to you." 

Nick 
[email protected] 

Peter Dijkstra

Thanks Maarten, everything is clear now! Although I have Stata8.2SE it
gave me an idea what keyword to look for. So for all Stata8 users:
*--------------- begin example -------------------
sysuse auto, clear
recode rep78 1/2 = 3

levels rep78
foreach lev in `r(levels)' {
	di _n _n as txt "rep78 = " as result `lev' 
	reg mpg wei if rep78 == `lev'
}
*---------------- end example --------------------

-------- Original-Nachricht --------
> Datum: Thu, 14 Feb 2008 09:46:48 +0000 (GMT)
> Von: Maarten buis <[email protected]>
> An: [email protected]
> Betreff: Re: st: Loop over all unique values of a variable

> --- Maarten buis <[email protected]> wrote:
> > -statsby- may also be convenient. It not performs those regressions
> > it also collects the results in a new dataset
> 
> I meant:
> It not only performs those regressions but it also collects the
results
> in a new dataset.

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