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@durham.ac.uk
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@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Jake Herb
Gesendet: Montag, 21. Februar 2005 19:17
An: statalist@hsphsun2.harvard.edu
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/