Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: sum of missing values returned as zero


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: sum of missing values returned as zero
Date   Sat, 4 Oct 2008 00:50:26 +0200

Note -egen, total- where you can add the -missing- option to toggle this behavior back and forth...

HTH
Martin
_______________________
----- Original Message ----- From: "Jacob Wegelin" <jwegelin@vcu.edu>
To: <statalist@hsphsun2.harvard.edu>
Sent: Saturday, October 04, 2008 12:44 AM
Subject: st: sum of missing values returned as zero



The following code

clear set obs 4
gen Finished=.
list
summarize Finished
return list

returns a value of zero for the sum of Finished, as is seen below. I do not understand. I would think that the sum of a list of numbers, at least one of which is missing, would be missing, not zero. Can someone explain?

. set obs 4
obs was 0, now 4

. gen Finished=.
(4 missing values generated)

. list

+----------+
| Finished |
|----------|
1. | . |
2. | . |
3. | . |
4. | . |
+----------+

. summarize Finished

Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
Finished | 0

. return list

scalars:
r(N) = 0
r(sum_w) = 0
r(sum) = 0


Thanks

Jacob A. Wegelin
jwegelin@vcu.edu Assistant Professor
Department of Biostatistics
Virginia Commonwealth University
730 East Broad Street Room 3006
P. O. Box 980032
Richmond VA 23298-0032
U.S.A. http://www.people.vcu.edu/~jwegelin

*
* 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index