```Date: Tue, 2 Nov 1999 16:24:27 -0500 Reply-To: Howard Schreier Sender: "SAS(r) Discussion" From: Howard Schreier Subject: Re: ROUND Fn Content-Type: text/plain; charset=US-ASCII This has intrigued me also. The results from the ROUND function can be expressed as a ratio of relatively small integers. One thing I stumbled across is a way to derive the denominators: data; do i = 1 to 20000; * Number to round, in range -50 to 50; notround = 100*(ranuni(1)-0.5); * Interval, in set .001, .002, .003, ... 1.000; round_to = input(put(ranuni(2),5.3),5.3) + 0.001; * SAS May be wrong; sasround = round(notround,round_to); * Workaround; myround = round(1000*notround,1000*round_to)/1000; denom = floor(1/round_to); numer = denom * sasround; output; end; run; proc print; run; The computed values for NUMER are all integers. Note the truncation via FLOOR in the formula for the denominator. If ROUND_TO has an integer reciprocal, there is no truncation, and the ROUND function is correct. ```

Back to: Top of message | Previous page | Main SAS-L page