Statalist


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

re: st: Collapse with sum function and missing values


From   "Airey, David C" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   re: st: Collapse with sum function and missing values
Date   Tue, 9 Feb 2010 22:06:33 -0600

.



. /* Worse is this example. */
. 
. clear

. 
. input group x

         group          x
  1. 1 10
  2. 1 11
  3. 1 12
  4. 2 20
  5. 2 21
  6. 2 22
  7. 3 .
  8. 4 -4
  9. 4 4
 10. end

. 
. collapse (sum) x , by(group)

. 
. list

     +------------+
     | group    x |
     |------------|
  1. |     1   33 |
  2. |     2   63 |
  3. |     3    0 |
  4. |     4    0 |
     +------------+

. 
. /* Note group 3 and 4 are the same. */
. 
end of do-file



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



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