Statalist


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

st: Collapse with sum function and missing values


From   Michael Mitchell <[email protected]>
To   [email protected]
Subject   st: Collapse with sum function and missing values
Date   Tue, 9 Feb 2010 18:50:53 -0800

Greetings

  I am befuddled by the following example that uses the -collapse-
command with the -(sum)- function...

. 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 .
  9. 4 .
 10. end

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

. list

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

  Shouldn't the value of -x- for groups 3 and 4 be missing, not zero.
To me, the sum of a series of missing values is a missing value. I am
doing a collapse for about 100 variables (100 x values) and need the
value to be defined as missing (not 0) in such cases. Any ideas?

Thanks,

Michael

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