Date: Thu, 5 Feb 2004 16:02:54 -0800
Reply-To: Dale McLerran <stringplayer_2@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Dale McLerran <stringplayer_2@YAHOO.COM>
Subject: Re: round to nearest even number
In-Reply-To: <4712306c.0402051402.2beba8d2@posting.google.com>
Content-Type: text/plain; charset=us-ascii
If you want to round to the nearest even integer when the value
of mod(abs(X),1)=0.5, then you have to do a little bit of work in
SAS version 8.x. Version 9.0 has the ROUNDE function which
addresses this functionality, but before version 9.0 you would
need to do something like the following:
if mod(abs(X),1)=.5 then do;
if mod(abs(X),2)=.5 then y=sign(x)*floor(abs(X));
else y=sign(x)*ceil(abs(X));
end;
else y=round(x,1);
A bit messy. There may be a more elegant solution, but I will
let others work that out.
Dale
--- knvsol <knvsol@COMCAST.NET> wrote:
> Trying to recreate in SAS what Cint does in vbscript. Basically what
> I need is to be able to round to nearest even number. ( i.e. 0.5--> 0
> and 1.5 -->2 etc.) any ideas?
>
> knvsol
=====
---------------------------------------
Dale McLerran
Fred Hutchinson Cancer Research Center
mailto: dmclerra@fhcrc.org
Ph: (206) 667-2926
Fax: (206) 667-5977
---------------------------------------
__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html