[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
re: st: Collapse with sum function and missing values
.
. /* 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/