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

st: RE: Rounding number

From   "Nick Cox" <>
To   <>
Subject   st: RE: Rounding number
Date   Mon, 3 Mar 2008 13:39:52 -0000

The help for -round()- is 

    round(x,y) or round(x)
       Domain x:     -8e+307 to 8e+307
       Domain y:     -8e+307 to 8e+307
       Range:        -8e+307 to 8e+307
       Description:  returns x rounded in units of y or x rounded to the
                         nearest integer if the argument y is omitted.

                     returns x (not ".") if x is missing, meaning that
                         round(.a) = .a and round(.a,y) = .a if y is not
                         missing; if y is missing, "." is returned.

                     For y = 1, or with y omitted, this amounts to the
                     closest integer to x; round(5.2,1) is 5, as is
                     round(4.8,1); round(-5.2,1) is -5, as is
                     The rounding definition is generalized for y != 1.
                     y = .01, for instance, x is rounded to two decimal
                     places; round(sqrt(2),.01) is 1.41. y may also be
                     than 1; round(28,5) is 30, which is 28 rounded to
                     closest multiple of 5.  For y = 0, the function is
                     defined as returning x unmodified.  Also see
                     ceil(x), and floor(x).

Instead of saying I don't understand, it is best to say specifically
what you do 
not understand. Which bits appear unclear, confused, incorrect? 

In this case, you could round 4.2 up to 5 by using -ceil()-. 

Round down with -floor()- 


Ziad El-Khatib

tried to look for help round but did not understand it well.
how to round variable (weight) to have it 0 decimal, e.g. 5 instead of

*   For searches and help try:

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