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

RE: st: help on round function


From   Richard Williams <[email protected]>
To   [email protected], <[email protected]>
Subject   RE: st: help on round function
Date   Sat, 10 Dec 2005 17:23:04 -0500

At 04:24 PM 12/10/2005, [email protected] wrote:
Fred,
I got that. But if I have a variable
X
8.575
7.995
10.324
and I do: gen y =round(x,.01), I get
Y       not  Y
8.57            8.58
7.99            8.00
10.32           10.32

what I need. What am I doing wrong?
Are you sure that 8.575 isn't really 8.57499999 or something like that? When I do

. set obs 1
obs was 0, now 1

. gen x = 8.575

. gen y = round(x, .01)

. list

+--------------+
| x y |
|--------------|
1. | 8.575 8.57 |
+--------------+

Looking at the data in the data editor, I see

x = 8.5749998
y = 8.5699997

-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal): http://www.nd.edu/~rwilliam
WWW (department): http://www.nd.edu/~soc
*
* 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