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

Re: st: sum() returns different results every time, why?

From   Tim <>
Subject   Re: st: sum() returns different results every time, why?
Date   Sun, 02 Aug 2009 10:30:58 +1000

My guess is decil and rincome do not uniquely identify the observations. In that case your sort order will not necessarily be the same, so you will be accumulating parting_exp in a different order each time.

Tim Badgery-Parker

Johanna Jiménez wrote:
Hi everyone,

I have a question for you....I have executed this code using the same
data, with 9940 observations, several times:

sort decil rincome

gen double rinc_exp= rincome * facexp

egen double totrinc_exp = total (rinc_exp)

gen double parting_exp= rinc_exp / totrinc_exp

gen double acumparting_exp= sum(parting_exp)

The problem is the last command.  Each time I execute it,
“acumparting_exp” changes, this means that the running sum of
“parting_exp” varies for each observation each time I run my do-file.
I don´t know why sum() is different every time. I have tried to change
storage type of variables, drop some observations, but always occurs
the same. Could someone help me, please?

Probably, my question is a little silly, but I don’t understand what
it’s happening and also, this has an effect on other commands and a
bootstrap program I wrote.   Besides, I executed these commands with
other variables as expenditures and I didn’t have the problem I
mentioned.  Just with incomes, commands return something different
every time.

(Note: rincome and facexp are double (storage type of variables); and
database is always the same.)

I appreciate your help.

Kind regards,

Johanna J.

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index