Statalist


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

st: AW: Collapse with sum function and missing values


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: Collapse with sum function and missing values
Date   Wed, 10 Feb 2010 09:18:29 +0100

<> 



To be fair, we should mention the -cw- option which, in your case, would
omit the groups 3 and 4 completely.



HTH
Martin

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Michael
Mitchell
Gesendet: Mittwoch, 10. Februar 2010 03:51
An: [email protected]
Betreff: st: Collapse with sum function and missing values

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/


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