Date: Thu, 5 Feb 2004 17:24:42 -0500
Reply-To: "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM>
Subject: Re: round to nearest even number
On Thu, 5 Feb 2004 14:02:41 -0800, 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?
>
hi, knvsol,
sas has an unusually generalized round function. See the documentation. An
example is in the below.
Cheers,
Chang
data one;
input v1;
v2 = round(v1, 2);
cards;
-1.7
-1.0
-0.5
0
0.7
1.0
1.1
1.4
2.0
;
run;
proc print;
run;
/* out lst
Obs v1 v2
1 -1.7 -2
2 -1.0 -2
3 -0.5 0
4 0.0 0
5 0.7 0
6 1.0 2
7 1.1 2
8 1.4 2
9 2.0 2
*/
|