/**********************************************************************/
data _null_;
x=0;
do i=1 to 10;
x+0.1;
end;
if x=1 then put 'x is equal to 1';
else put 'what happened?';
run;
/**********************************************************************/
x=0;
do i=1 to 10;
x+0.1;
end;
if x=1 then put 'x is equal to 1';
else put 'x is not equal to 1';
/**********************************************************************/
proc format;
picture penny low-high='000,000,009.99'
(mult=1 prefix='$');
run;
/**********************************************************************/
x=0;
do i=1 to y;
x+1/y;
end;
/**********************************************************************/
x=0;
do i=1 to y;
x+1/y;
end;
x=ROUND(x,1);
/**********************************************************************/
data _null_;
fuzz=1*16**-11;
x=256.115;
y=round(x+fuzz, .01);
put _all_;
run;
/**********************************************************************/
x=0;
do i=1 to y;
x+1/y;
end;
/**********************************************************************/
if abs(x-y)<1e-12 then TRUE;
else FALSE;
/**********************************************************************/
%macro eqfuzz(var1, var2, fuzz=1e-12);
abs(&var1-&var2)<&fuzz
%mend;
/**********************************************************************/
data _null_;
x=0;
do i=1 to 10;
x+0.1;
end;
y=1;
if x=y then
put 'x exactly equal to y';
else if %eqfuzz(x,y) then
put 'x close enough to y';
else put 'x not even close to y';
run;
/**********************************************************************/
%macro eqfuzz(var1,var2,fuzz=1e-12);
abs((&var1-&var2) / &var1)<&fuzz
%mend;
/**********************************************************************/
data merged;
merge ds1 /* contains variables b and x */
ds2; /* contains variables b and y */
by b;
run;
/**********************************************************************/
proc sql;
create table joined as
select ds1.b,x,y
from ds1 full join ds2
on %eqfuzz(ds1.b, ds2.b);
/**********************************************************************/