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

RE: st: Pick up the maximal value


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Pick up the maximal value
Date   Mon, 24 Mar 2003 14:29:37 -0000

jtsheu@bu.edu
> 
> Thanks for Jesper's reply.
> however, this is not the situation I want.
> >From your program, based on the example data in my previous email.
> We will get:
> 
> obs  x  dis  maxdis
> 1    0   23   23
> 2    0   12   23
> 3    0   25   23
>    (Since 23 is the second best when x==0)
> 4    1   23   25
> 5    1   25   25
> 6    1   26   25
> 
> However, the result I want should be 
> 
> obs x  dis   maxdis
> 1   0   23     25 (since 25 is the max for x==0 among 
> observations except obs 1)
> 2   0   12     25 (since 25 is the max for x==0 among 
> observations except obs 2)
> 3   0   25     23 (Since 23 is the max for x==1 among 
> observations except obs 3)
> 4   1   23     26
> 5   1   25     26
> 6   1   26     25
> 
> any suggestion?

There is an FAQ 

How do I create variables summarizing for each individual 
properties of the other members of a group?

at 

http://www.stata.com/support/faqs/data/members.html

which discusses this problem as well as others
in this territory. One broader context, of becoming 
more familiar with the range of functions, is 
written up in Stata Journal 2(4):411--427 (2002). 

Nick 
n.j.cox@durham.ac.uk 
*
*   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/



*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index