[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Vitorino, Maria Ana" <vitorino@wharton.upenn.edu> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: AW: dealing with duplicate "pairs" of columns |

Date |
Thu, 11 Feb 2010 03:01:29 -0500 |

Thanks! This is very helpful! Maria Ana On Feb 10, 2010, at 8:36 AM, "Martin Weiss" <martin.weiss1@gmx.de> wrote: > > <> > > > > ************* > clear* > > input byte(Person1_id ClosestPerson Person1_age) > 1 2 10 > 2 1 20 > 3 1 30 > 4 3 40 > end > > gen lower=min( Person1_id, ClosestPerson) > gen upper=max( Person1_id, ClosestPerson) > bys lower upper ( Person1_age): gen byte dup=!(_N==1) > by lower upper ( Person1_age): replace dup=2 if _n==_N &dup!=0 > l, noo > ************* > > > > HTH > Martin > > > -----Ursprüngliche Nachricht----- > Von: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von > Vitorino, Maria > Ana > Gesendet: Mittwoch, 10. Februar 2010 15:21 > An: statalist@hsphsun2.harvard.edu > Betreff: st: dealing with duplicate "pairs" of columns > > Hi all, > I was wondering if there was a relatively simple way to achieve the > following: > > My data looks like this: > > Person1_id ClosestPerson Person1_age > 1 2 10 > 2 1 20 > 3 1 30 > 4 3 40 > ... > > What I would like to do is to signal "duplicate" rows for which > Person1 is > the oldest. Since this is hard to explain, the resulting data would > be for > the example above: > > Person1_id ClosestPerson Person1_age dup > 1 2 10 > 1 > 2 1 20 > 2 > 3 1 30 > 0 > 4 3 40 > 0 > ... > > Note that the column dup has the following coding: > dup=1 if there is another pair of ppl identical to the one in this > row and > Person1 is the youngest of the pair > dup=2 if there is another pair of ppl identical to the one in this > row and > Person1 is the oldest of the pair > dup=0 if there is no other pair of ppl identical to the one in this > row > > Hope this isn't too confusing... > Suggestions are welcome! > > Thanks, > Maria Ana > > > * > * 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/ > > > * > * 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/ * * 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/

**References**:**st: dealing with duplicate "pairs" of columns***From:*"Vitorino, Maria Ana" <vitorino@wharton.upenn.edu>

**st: AW: dealing with duplicate "pairs" of columns***From:*"Martin Weiss" <martin.weiss1@gmx.de>

- Prev by Date:
**Re: st: A command for a simultaneous model with an ordinal dependent variable?** - Next by Date:
**Re: st: RE: AW: dealing with duplicate "pairs" of columns** - Previous by thread:
**Re: st: RE: AW: dealing with duplicate "pairs" of columns** - Next by thread:
**st: Re: Updated ivreg2, xtivreg2 cluster option.** - Index(es):

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