# 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
round(-4.8,1).
The rounding definition is generalized for y != 1.
With
y = .01, for instance, x is rounded to two decimal
places; round(sqrt(2),.01) is 1.41. y may also be
larger
than 1; round(28,5) is 30, which is 28 rounded to
the
closest multiple of 5.  For y = 0, the function is
defined as returning x unmodified.  Also see
int(x),
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()-

Nick
n.j.cox@durham.ac.uk

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
4.20?

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