Solved
Contributor
Posts: 24

# SAS Proc Report Decimal point highlight issue

[ Edited ]

deleted

Accepted Solutions
Solution
‎01-31-2018 05:50 AM
Super User
Posts: 8,260

## Re: SAS Proc Report Decimal point highlight issue

You are rounding in the wrong place.  Let's convert your test data into a dataset and try to report it.  First let's show the value of the actual difference between the absolute values and then round that difference.

``````data have ;
input Value1	Value2	ExpectedDiff ;
copy2=value2;
diff1=abs(value1)-abs(value2) ;
diff2=round(diff1,0.01);
format diff: 20.17 ;
cards;
62.21 -62.22 -0.01
65.89 -65.88 0.01
-78.3 78.39 -0.09
-89.87 89.85 0.02
. . .
;
proc print data=have ;
run;
``````

Now let's try it with PROC REPORT.

``````proc report data=have ;
define _all_ / display ;
compute value2 ;
if abs(round(abs(value1)-abs(value2),0.01)) > 0.01 then
call define (_col_,"style","style={background= orange}")
;
endcomp;
compute copy2;
if ((abs(round(value1,0.01)) - abs(round(value2,0.01)) < -0.01)
or (abs(round(value1,0.01)) - abs(round(value2,0.01)) >0.01)) then
call define (_col_,"style","style={background= orange}")
;
endcomp;
run;``````

All Replies
PROC Star
Posts: 1,332

## Re: SAS Proc Report Decimal point highlight issue

For the columns in AMTPREMIUM_QIS that appear to be improperly flagged, I believe that you've run into the problem with floating point variables that decimals can't be exactly represented in binary.

``````data Demonstrate;

Flag1 = 1;
else Flag1 = 0;

Flag2 = 1;
else Flag2 = 0;
putlog Flag1= Flag2=;
run;
``````

On your AMTEXTFORPAYPERI_QIS issue, because AMTEXTFORPAYPERI is missing, the entire equation will come out to missing, and I believe that missing values are considered less than any number.

Tom

Solution
‎01-31-2018 05:50 AM
Super User
Posts: 8,260

## Re: SAS Proc Report Decimal point highlight issue

You are rounding in the wrong place.  Let's convert your test data into a dataset and try to report it.  First let's show the value of the actual difference between the absolute values and then round that difference.

``````data have ;
input Value1	Value2	ExpectedDiff ;
copy2=value2;
diff1=abs(value1)-abs(value2) ;
diff2=round(diff1,0.01);
format diff: 20.17 ;
cards;
62.21 -62.22 -0.01
65.89 -65.88 0.01
-78.3 78.39 -0.09
-89.87 89.85 0.02
. . .
;
proc print data=have ;
run;
``````

Now let's try it with PROC REPORT.

``````proc report data=have ;
define _all_ / display ;
compute value2 ;
if abs(round(abs(value1)-abs(value2),0.01)) > 0.01 then
call define (_col_,"style","style={background= orange}")
;
endcomp;
compute copy2;
if ((abs(round(value1,0.01)) - abs(round(value2,0.01)) < -0.01)
or (abs(round(value1,0.01)) - abs(round(value2,0.01)) >0.01)) then
call define (_col_,"style","style={background= orange}")
;
endcomp;
run;``````

☑ This topic is solved.

Discussion stats
• 2 replies
• 190 views
• 0 likes
• 3 in conversation