Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: RE: RE: Re: How to speed up loop


From   "David E Moore" <[email protected]>
To   [email protected]
Subject   st: RE: RE: RE: RE: Re: How to speed up loop
Date   Mon, 20 Sep 2004 11:26:21 -0700

While it is doubtless clear from the example what was meant, there is
nonetheless a typo that might throw off a newcomer to the wonderful world of
variable indexing.  In the nicely worked example presented by Nick he translates
the expression "age[mlineno]" as "age[3]" when, in fact, it should have been
"age[2]."  I mention this because it's really a tricky concept for someone not
accustomed to using variables as indexes.  If you didn't already grasp the
principles involved, taking the values literally might leave you hopelessly
confused.  So, in the excerpt quoted below, substitute "age[2]" for "age[3]" and
"second" for "third" to see the correct connections.

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Nick Cox
> Sent: Friday, September 17, 2004 4:52 AM
> To: [email protected]
> Subject: st: RE: RE: RE: Re: How to speed up loop
>
       <snip>
> Take
>
> hhid    lineno       age   mlineno      mage
>   1         1        32         .         .
>   1         2        30         .         .
>   1         3         5         2        30
>
> Each expression within [ ] is evaluated
> separately for each observation. For
> the first and second
>
> 	age[mlineno] becomes age[.]
>
> which is taken as missing. For the third,
>
> 	age[mlineno] becomes age[3]
>
> which by the wrinkle rule above is 30.
> It is the third observation _within that group_.

      <snip>


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