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

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

From   Johanna Jiménez <>
Subject   st: sum() returns different results every time, why?
Date   Sat, 1 Aug 2009 20:21:51 -0400

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