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

Re: st: AW: Combining duplicate observations rather than deleting them


From   "jake10002002" <[email protected]>
To   [email protected]
Subject   Re: st: AW: Combining duplicate observations rather than deleting them
Date   Mon, 28 Feb 2005 15:13:54 -0000

Hi Guys,
Thanks for your suggestions! I resolved the issue. The bysort method 
that Nick Cox suggested seems to be more useful for me, since it 
keeps the other many variables I have in the dataset whereas the --
collapse-- command drops all these other variables.
Thanks again,
Jake
--- In [email protected], "Armen Khachatryan" <armen@u...> 
wrote:
> Hi Jake,
> 
> Actually Nick Cox addressed you question yesterday (see below after 
Eric G.
> Wruck's suggestion).
> 
> 
>  
> 
> How about this?
> 
> . sort read race
> 
> . collapse (sum) write, by(read race)
> 
> . l
> 
>      +---------------------+
>      | read   race   write |
>      |---------------------|
>   1. |   40      1     100 |
>      +---------------------+
> 
> .
> Eric
> ����������������������������________________________________________________
> ____________________________________
> 
> -collapse- 
> 
> alternatively, 
> 
> bysort read race : replace write = sum(write) by read race : keep 
if _n ==
> _N 
> 
> Nick
> n.j.cox@d... 
> 
> 
> Armen Khachatryan
> PhD Research Fellow, Scientific Assistant
> Institute for Farm Management (410B)
> University of Hohenheim
> Schloss Osthof-Sued
> 70599 Stuttgart, Germany
>  
> Tel: +49 711 459 4264 
> Fax: +49 711 459 3709 
> 
> -----Urspr�ngliche Nachricht-----
> Von: owner-statalist@h...
> [mailto:owner-statalist@h...] Im Auftrag von Jake Herb
> Gesendet: Montag, 21. Februar 2005 19:17
> An: statalist@h...
> Betreff: st: Combining duplicate observations rather than deleting 
them
> 
> Dear Users,
> I have duplicate observations in my dataset but rather than 
deleting them
> using "dups" for example, I'd like to combine them and summarize a 
certain
> variable.
> 
> For instance, I have:
> 
> obs# read race write
> 1    40   1    30
> 2    40   1    70
> 
> Which are duplicate based on the variables "read" and "race". I'd 
like to
> combine the two observations into one observation, which sums 
the "write"
> variable, so at the end of the day I have in the dataset:
> 
> obs# read race write
> 1    40   1    100
> 
> Any thoughts/suggestions would be greatly appreciated!
> Thanks,
> Jake
> 
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - Helps protect you from nasty viruses.
> http://promotions.yahoo.com/new_mail
> *
> *   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/
> 
> --
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.300 / Virus Database: 266.2.0 - Release Date: 
21.02.2005
>  
> 
> -- 
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.300 / Virus Database: 266.2.0 - Release Date: 
21.02.2005
>  
> 
> 
> *
> *   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index