Date: Mon, 28 Sep 2009 14:01:17 -0700
Reply-To: xlr82sas <xlr82sas@AOL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: xlr82sas <xlr82sas@AOL.COM>
Organization: http://groups.google.com
Subject: Re: SAS drove me crazy! Please help me!
Content-Type: text/plain; charset=ISO-8859-1
On Sep 25, 5:06 pm, ms...@albany.edu (Mike Zdeb) wrote:
> hi ... I guess you can keep going on with this ...
>
> mark = (fuzz(copay) eq 5);
>
> --
> Mike Zdeb
> U@Albany School of Public Health
> One University Place
> Rensselaer, New York 12144-3456
> P/518-402-6479 F/630-604-1475
>
>
>
> > On Fri, 25 Sep 2009 16:50:00 -0400, Chang Chung <chang_y_ch...@HOTMAIL.COM>
> > wrote:
> > ...
> >> if copay - 5 < 0.001 then mark = 1;
> >> else mark = 0;
>
> > I meant absolute value of the difference, of course: (wink, wink)
>
> > if abs(copay-5) < 0.001 then mark = 1;
>
> > Also, privately, Howard reminded me that the fuzz() function is exactly
> > intended for something like this. fuzz(x) returns the nearest integer value
> > of x if the x is within 1e-12 of that integer; otherwise it returns x, as
> > is. So, the above line could be:
>
> > if fuzz(copay) eq 5 then mark = 1;
> > else mark = 0;
>
> > Thanks, Howard!
>
> > Cheers,
> > Chang- Hide quoted text -
>
> - Show quoted text -
Dollaes and cents and decimal arithmetic.
If you are doing calculations on dollars and cents ie $10.11, $20.61
and you want precise results to the penny, even after extensive
manipulation of the numbers then do the following
untested code.
data pennies;
one=10.11;
two=10.61;
income1=fuzz(100*one);
income2=fuzz(100*two);
income11=income1+20; /* adding 20 pennies instead of adding 0.20
dollars */
income22=income2+20; /* adding 20 pennies instead of adding 0.20
dollars */
dif=income22-income11;
/* at the very end convert to dollars */
if dif=50 then do;
dollars=dif/100;
put dollars 5.2;
end;
run;
|