Amani:
Stata 8.2 doesn't show this behaviour:
. input x
x
1. 8.750
2. 5.752
3. 23.256
4. end
. gen y = round(x, 0.1)
. list
+---------------+
| x y |
|---------------|
1. | 8.75 8.8 |
2. | 5.752 5.8 |
3. | 23.256 23.3 |
+---------------+
Maybe 8.750 in your data is actually 8.7499?
HTH,
Maarten
-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands
visiting adress:
Buitenveldertselaan 3 (Metropolitan), room Z214
+31 20 5986715
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Siyam, Amani
Sent: donderdag 13 april 2006 15:05
To: [email protected]
Subject: st: rounding in STATA
I have a minor issue with the way STATA is rounding, for example a
variable to one decimal place.
I used the command
gen x=round(y, 0.1)
Comparing the two variables, I noticed the that when:
x= y=
8.750 8.7
5.752 5.8
23.256 23.3
Is there a way I can modify the function to round "x"=8.750 to be 8.8
Or should I put together my own code to get the rounding I want.
*
* 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/