Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, 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 <firstname.lastname@example.org>
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: email@example.com [mailto:firstname.lastname@example.org] On Behalf Of Carla Horlacher
> Sent: 14 September 2011 11:24
> To: email@example.com
> 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: