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

Re: st: Combining duplicate observations rather than deleting them


From   "Eric G. Wruck" <[email protected]>
To   [email protected]
Subject   Re: st: Combining duplicate observations rather than deleting them
Date   Mon, 21 Feb 2005 21:31:20 -0500

How about this?

. sort read race

. collapse (sum) write, by(read race)

. l

     +---------------------+
     | read   race   write |
     |---------------------|
  1. |   40      1     100 |
     +---------------------+

.
Eric


>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


-- 

===================================================

       Eric G. Wruck
       Econalytics
       2535 Sherwood Road
       Columbus, OH  43209

       ph:      614.231.5034
       cell:    614.327.4182
       fax:     614.231.5039
       eFax:    614.573.6639
       eMail:   [email protected]
       website: http://www.econalytics.com

====================================================
*
*   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