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

st: AW: Combining duplicate observations rather than deleting them


From   "Armen Khachatryan" <[email protected]>
To   <[email protected]>
Subject   st: AW: Combining duplicate observations rather than deleting them
Date   Tue, 22 Feb 2005 21:39:18 +0100

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
[email protected] 


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: [email protected]
[mailto:[email protected]] Im Auftrag von Jake Herb
Gesendet: Montag, 21. Februar 2005 19:17
An: [email protected]
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/



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