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

# Re: st: Precision issues with double storage type (??)

 From Maarten buis To statalist@hsphsun2.harvard.edu Subject Re: st: Precision issues with double storage type (??) Date Tue, 7 Aug 2007 00:10:29 +0100 (BST)

```--- Hiroshi Maeda <hmaeda1@uic.edu> wrote:
> I first create two observations, each of which has three variables of
> a financial nature: DEPOSIT_A (amount of money deposited to procure a

> service), PAYMENT_A (amount of money actually paid), and REFUND_A
> (amount of money refunded). The mathematical relationship among them
> is: DEPOSIT_A=PAYMENT_A+REFUND_A. Since I am in the U.S., the figures
> are in U.S. dollars.
>
> The data look like this:
>
> ID     DEPOSIT_A     PAYMENT_A     REFUND_A
>
> 1      61.42         21.30         40.12
>
> 2      69.00         68.49           .51
>
> But when I type:
>
> gen CHECK_2=1 if float(DEPOSIT_A)==float(PAYMENT_A)+float(REFUND_A),
>
> Stata fails to recognize this relationship in observation 2

<snip>

A common trick with financial data is to store money amounts not as
dollars but as dollar cents. The reason is that now the numbers are
integers (no numbers behind the decimal point) and integers can be
stored precisely. See the example below:

If you want to learn more about precision I can highly reccomend (Gould
2006), it is a really clear text from which I learned a lot.

Hope this helps,
Maarten

*---------------- begin example --------------------
drop _all
input long ID  long   DEPOSIT_A  long   PAYMENT_A  long   REFUND_A
1      6142         2130         4012
2      6900         6849           51
end
gen CHECK_2=1 if DEPOSIT_A==PAYMENT_A+REFUND_A
list CHECK_2
*--------------- end example ------------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

William Gould (2006), "Mata Matters: Precision". The Stata Journal,
6(4), pp. 550 -- 560.

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------

___________________________________________________________
Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for
your free account today http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```

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