<>
Also note http://www.stata.com/support/faqs/data/float.html
I get answers different from yours, both in Stata 10.1 and 11, possibly b/c your dataset is not created by the code that you showed in your reply? I assume this is the case as your -list- command shows the "dummy" although it is -generate-d in the following line...
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] Im Auftrag von Ulrich Kohler
Gesendet: Dienstag, 15. September 2009 13:33
An: [email protected]
Betreff: Re: st: AW: Diffrence between sum and tabsum
<>
yes, I thought about that. However, the following bit shows that your
example is not quite the problem here
. set obs 3
. gen byte coreweight1968=18
. gen double firstweight = coreweight1968 * 60468000/78028
. format firstweight %32.20f
. l
+-----------------------------------------------+
| cor~1968 firstweight dummy |
|-----------------------------------------------|
1. | 18 13949.14646024503963417374 1 |
2. | 18 13949.14646024503963417374 1 |
3. | 18 13949.14646024503963417374 1 |
+-----------------------------------------------+
. gen dummy = 1
. tab dummy, sum(firstweight)
| Summary of firstweight
dummy | Mean Std. Dev. Freq.
------------+------------------------------------
1 | 13949.146 .00024815 3
------------+------------------------------------
Total | 13949.146 .00024815 3
However you are right that is should be some kind of a precision
problem. In fact
. replace firstweight = coreweight1968 * 4/3
. tab dummy, sum(firstweight)
works as expected.
Am Dienstag, den 15.09.2009, 12:54 +0200 schrieb Martin Weiss:
> <>
>
>
> Probably a precision issue as in
>
> ***
>
> clear*
>
> inp double firstweight
> 13949.1460454864
> 13949.146248765
> 13949.146324324
> end
>
>
> gen byte dummy=1
>
> su firstweight
>
> tab dummy, /*
> */ sum(firstweight)
>
> ***
>
>
>
> HTH
> Martin
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von Ulrich Kohler
> Gesendet: Dienstag, 15. September 2009 12:14
> An: statalist
> Betreff: st: Diffrence between sum and tabsum
>
> <>
>
> Does anybody know why -tabulate, summarize- displays a nonzero
> standard-deviation for a variable that is a constant?
>
> . tab seopsu if seopsu==948, sum(firstweight)
>
> Cps Pr |
> Sampl Un | Summary of firstweight
> 5:71-73 | Mean Std. Dev. Freq.
> ------------+------------------------------------
> 948 | 13949.146 .00024815 3
> ------------+------------------------------------
> Total | 13949.146 .00024815 3
>
> . sum firstweight if seopsu==948
>
> Variable | Obs Mean Std. Dev. Min Max
> -------------+--------------------------------------------------------
> firstweight | 3 13949.15 0 13949.15 13949.15
>
> . return list
>
> scalars:
> r(N) = 3
> r(sum_w) = 3
> r(mean) = 13949.14646024504
> r(Var) = 0
> r(sd) = 0
> r(min) = 13949.14646024504
> r(max) = 13949.14646024504
> r(sum) = 41847.43938073512
>
> . d firstweight
>
> storage display value
> variable name type format label variable label
> ----------------------------------------------------------------------------
> ------
> firstweight double %10.0g
>
> . l firstweight if seopsu==948
>
> +-----------+
> | firstwe~t |
> |-----------|
> 4256. | 13949.146 |
> 4365. | 13949.146 |
> 4537. | 13949.146 |
> +-----------+
>
> . about
>
> Stata/MP 11.0 for Unix (Linux 64-bit x86-64)
> Born 26 Aug 2009
> Copyright (C) 1985-2009
>
>
>
> *
> * 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/
*
* 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/