Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: RE: round
Nick Cox <email@example.com>
Re: st: RE: round
Wed, 14 Sep 2011 11:54:15 +0100
I recommend otherwise.
Confusing (1) what decimal number you want stored, (2) how that is
held in binary and (3) what is to be displayed, which is really a
string, is a recipe for frustration.
To get a display to so many decimal places, use the appropriate
-format-. -round(whatever, .01)- just replaces one binary
approximation by another. Most multiples of .01 cannot be held
-round()- is a very useful function for rounding to (multiples of)
integers. It is also defined, evidently, for non-integer second
arguments, but that does not mean it can deliver the impossible.
Over the years on Statalist, this question has I guess wildly appeared
hundreds of times. -search precision- for blog entries, articles and
FAQs on the subject, starting with anything written by Bill Gould.
On Wed, Sep 14, 2011 at 11:37 AM, Tim Evans <Tim.Evans@wmciu.nhs.uk> wrote:
> Would the following do the trick for you?
> gen real=round(obs, .01)
> Substitute real with the name of what you want to call your variable and replace obs with the name of the variable containing the .4378
> -----Original Message-----
> From: firstname.lastname@example.org [mailto:email@example.com] On Behalf Of Carla Horlacher
> Sent: 14 September 2011 11:24
> To: firstname.lastname@example.org
> Subject: st: round
> Hallo all!
> I have a quick question:
> how do I round numbers like .4378 to get only 2 digits after the point?
* For searches and help try: