Statalist


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

Re: st: obs no of max value


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: obs no of max value
Date   Tue, 23 Sep 2008 08:39:03 -0500

Note that the final statement quoted below is quite false. The -generate- statement will record _n in every observation for which the -if- condition is satisfied.

A more detailed discussion of the underlying question is found in

SJ-6-4 dm0025 . . . . . . . . . . Stata tip 36: Which observations? Erratum
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
Q4/06 SJ 6(4):596 (no commands)
correction of example code for Stata tip 36

SJ-6-3 dm0025 . . . . . . . . . . . . . . Stata tip 36: Which observations?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
Q3/06 SJ 6(3):430--432 (no commands)
tip for identifying which observations satisfy some
specified condition

Nick
[email protected]

Ashim Kapoor wrote:


Suppose I have a variable " Age". I wish to find out at which
observation does age have a max at. One way to do this is to write a
while loop. I think that's horrid.

I guess I could do : -

egen mAge=max(Age)

gen index=_n if Age==mAge

But this puts the right value of _n only in ONE observation.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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