BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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;

image.png

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;

image.png

 

View solution in original post

2 REPLIES 2
TomKari
Onyx | Level 15

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;
	AMTPREMIUM = 62.34;
	AMTPREMIUM_6970CarGlass = 62.33;

	if AMTPREMIUM - AMTPREMIUM_6970CarGlass > .01 then
		Flag1 = 1;
	else Flag1 = 0;

	if AMTPREMIUM - AMTPREMIUM_6970CarGlass > .011 then
		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

Tom
Super User Tom
Super User

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;

image.png

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;

image.png

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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