LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 1999, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 2 Nov 1999 16:24:27 -0500
Reply-To:     Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
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