Date: Wed, 16 Jan 2008 19:52:35 -0500
Reply-To: Lou <lpogodajr292185@COMCAST.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Lou <lpogodajr292185@COMCAST.NET>
Subject: Re: numeric precision
"Jack Hamilton" <jfh@STANFORDALUMNI.ORG> wrote in message
> Instead of storing $1234.56 as 1234.56, I would store it as 123456, and
> display it with a user-written format.
> I first ran into the problem with PROC SUMMARY, but have encountered it
> elsewhere also. It seems to depend on both the range of the numbers and
> the order in which they are added. I'm sure a computer scientist could
> tell us all about it.
I'll second that - when I started using SAS 20+ years ago, I was working in
accounting/finance, and it took only a day or two to notice precision
problems. The size of the numbers, be they a few bucks or trillions, is
irrelevant. I right from the start switched to intergers (in effect,
carrying the dollar amounts in pennies) and displaying the results with a
user written format.
As long as multiplication and division of these amounts involve only
integers, the technique almost always works fine - the decimal point always
goes in the same place. I say almost because once, after a long series of
arithmetic operations, I came up with a result that should have equalled 60
(I could test one or two instances by hand), but the machine stubbornly
refused to consider it equal to 60, even after using the INT function.