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 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 28 Nov 2007 11:25:19 -0600
Reply-To:   "data _null_," <datanull@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "data _null_," <datanull@GMAIL.COM>
Subject:   Re: Arithmetic precision comparison
Comments:   To: "Richard A. DeVenezia" <rdevenezia@wildblue.net>
In-Reply-To:   <EDe3j.2$Z54.89176@news.sisna.com>
Content-Type:   text/plain; charset=ISO-8859-1

Stealing Ian's idea to print with BEST and hope that gives enough information.

%macro MaxPrecision(arg1,arg2); 10**-(max(max(indexc(reverse(put(&arg1,best12.)),'.')-1,0),max(indexc(reverse(put(&arg2,best12.)),'.')-1,0))) %mend MaxPrecision;

On Nov 28, 2007 8:03 AM, Richard A. DeVenezia <rdevenezia@wildblue.net> wrote: > Tree Frog wrote: > > Richard > > > > Does this fit the bill? > > > > %macro maxprecision(ul,ll); > > %let ind_ul=%sysfunc(index(&ul,.)); > > %let rem_ul=%sysfunc(substr(&ul,%eval(&ind_ul+1))); > > %let lgt_ul=%sysfunc(length(&rem_ul)); > > %let ind_ll=%sysfunc(index(&ll,.)); > > %let rem_ll=%sysfunc(substr(&ll,%eval(&ind_ll+1))); > > %let lgt_ll=%sysfunc(length(&rem_ll)); > > %if %eval(&lgt_ul>&lgt_ll) %then %do; > > %let lgtf=z&lgt_ul..; > > %end; > > %else %do; > > %let lgtf=z&lgt_ll..; > > %end; > > 0.%sysfunc(sum(1),&lgtf) > > %mend; > > > > Tree Frog > > Unfortunately, no. I want a macro that generates a piece of DATA step code > (or a piece of SQL code) that functionally computes the maxprecision of > values in two variables (or expressions) -- not the values as found in two > macro variables. > > With this program, the log should show status=pass for all x's < 5.55. > > %macro maxprecision(expr1,expr2); > ... ? ... > %mend; > > data foo; > ll = 3; > ul=5.5; > > do x = 5.5485 to 5.5525 by 0.0001; > > if ( Round(X,%MAXPRECISION(LL,UL)) < LL ) then > status = 'fail-low'; > else > if ( Round(X,%MAXPRECISION(LL,UL)) > UL ) then > status = 'fail-high'; > else > status = 'pass'; > > put status=; > end; > run; > > -- > Richard A. DeVenezia > http://www.devenezia.com/ > > > > > > > On Nov 28, 2:48 pm, "Richard A. DeVenezia" <rdevene...@wildblue.net> > > wrote: > >> Consider two values, lower limit and upper limit. > >> LL: 1 > >> UL: 3.25 > >> And some computed value X that has to be evaluated against the > >> limits. X: 2.314159 > >> > >> The evaluation that has to be done is > >> LL <= Round(X,0.01) <= UL > >> > >> The 0.01 (10**-2) comes from the arithmetic precision of UL (2). > >> > >> Can anyone think up a functional form macro, > >> %MAXPRECISION(expr1,expr2), that could be used as such: > >> > >> if ( Round(X,%MAXPRECISION(LL,UL)) < LL ) then > >> status = 'fail-low'; > >> else > >> if ( Round(X,%MAXPRECISION(LL,UL)) > UL ) then > >> status = 'fail-high'; > >> else > >> status = 'pass'; > >> > >> I _don't_ have to deal with the situation where precision of > >> comparison cannot be inferred from the LL and UL. (Such a situation > >> would be LL=1.00 and UL=3.00, SAS would have no way, from the UL & > >> LL values alone, to know that 2 decimal places of precision are > >> desired) >


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