Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: problem with "statacommand if baz == float(#)"


From   "Guillaume R. Frechette" <[email protected]>
To   [email protected]
Subject   st: problem with "statacommand if baz == float(#)"
Date   Mon, 18 Nov 2002 09:19:07 -0500

Dear Statlisters: I apologize in advance as this is another version of a basic question that has been dealt with before on the list and in the FAQ, but I don't know how to solve this particular variant of it. The basic problem is to get Stata to recognize number that have a finite representation in decimal but not in binary (or a finite representation with more digits than the precision of Stata). For example:

. gen foo = 1/3

. tab foo if foo == 1/3
no observations

To which the solution is

. tab foo if foo == float(1/3)

foo | Freq. Percent Cum.
------------+-----------------------------------
.3333333 | 1257 100.00 100.00
------------+-----------------------------------
Total | 1257 100.00

But what about the following example

. gen foo = 1/3

. gen bar = 1/3

. gen baz = 1-foo-bar

. tab baz if baz == float(1/3)
no observations

. tab baz

baz | Freq. Percent Cum.
------------+-----------------------------------
.3333333 | 1257 100.00 100.00
------------+-----------------------------------
Total | 1257 100.00

The float command doesn't solve the problem. Can someone tell me how to get Stata to understand what I mean by 1/3?

Thanks in advance.

g


Guillaume R. Frechette
http://www.people.hbs.edu/gfrechette/html/econ.htm


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