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

st: RE: obs no of max value

From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: obs no of max value
Date   Tue, 23 Sep 2008 09:21:35 +0200

As long as you do not want to use -by- you can

sysuse auto, clear
su trunk, mean
g byte maxtag=1 if trunk==r(max)


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Ashim Kapoor
Sent: Tuesday, September 23, 2008 9:16 AM
To: [email protected]
Subject: st: obs no of max value

Hello everyone,

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. I can
play around with 0's and use egen total to get this in ALL
observations  , but I was wondering if anyone knew a DIRECT way of
doing this in one go.

Thank you,
*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index