Statalist The Stata Listserver


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

st: RE: RE: rounding in STATA


From   "Siyam, Amani" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: rounding in STATA
Date   Thu, 13 Apr 2006 15:34:31 +0200

Thanks for your reply Maarten, the values of x are exact ones and that
happens whenever you have "50" after the decimal you are cutting, for
example 0.*50, for the one decimal place, 0.**50 for the two decimal
place...etc.

Thanks for you help in advance.

Amani

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Maarten Buis
Sent: 13 April 2006 15:14
To: [email protected]
Subject: st: RE: rounding in STATA

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/

*
*   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