DATA Step, Macro, Functions and more

Comparing Values with different informats

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 123
Accepted Solution

Comparing Values with different informats

[ Edited ]

Here is a snapshot of some original data (the dataset is much larger)

 

PayAmountOGValues.PNG

 

Here is a snapshot of the proc contents for this dataset (side question- how can DOLLAR16.2 be an informat?)

 

PayAmount.PNG

 

I'm doing this work in EG, and what I'm trying to attempt to do either in a program or query builder is compare the values of ApprovedMemberPay and ApprovePatientPayAmount and return rows where they don't match, so when I try comparing them right off the bat without doing anything to the variables but simply using the condition "where ApprovedPatientPayAmount ne ApprovedMemberPay" I get a dataset showing the same values (below), which is the opposite of what I want.

 

PayAmountResults.PNG

 

how can I change formats/informats to compare the two values correctly?


Accepted Solutions
Solution
‎11-29-2016 01:03 PM
Super User
Posts: 5,498

Re: Comparing Values with different informats

Posted in reply to JediApprentice

Try adding another variable:

 

difference = ApprovedMemberPay - approvedPatientPayAmount;

 

I suspect the values will be tiny, like 1E-15.  If that turns out to be true, it will be helpful information for you to decide on the next step.

View solution in original post


All Replies
Super User
Posts: 5,498

Re: Comparing Values with different informats

Posted in reply to JediApprentice

Most likely, you are already comparing the values correctly.  But the report doesn't illustrate that because of the formats.  It seems likely that the variables are different somewhere beyond the second digit after the decimal point.

 

To test that, remove the format in the new data set:

 

data want;

set have;

where ApprovedPatientPayAmount ne ApprovedMemberPay;

format ApprovedPatientPayAmount  ApprovedMemberPay;

run;

 

By removing the formats, you will be able to see the actual values instead of the formatted values.

Contributor
Posts: 74

Re: Comparing Values with different informats

Posted in reply to JediApprentice

You can just remove the informats and formats. 

eg.

informat ApprovedMemberPay;

format ApprovedMemberPay;

 

 

 

Frequent Contributor
Posts: 123

Re: Comparing Values with different informats

This is the code I used:

data want;
  set data;
  where ApprovedMemberPay ne ApprovedPatientPayAmount;
  format ApprovedMemberPay ApprovedPatientPayAmount;
  informat ApprovedMemberPay ApprovedPatientPayAmount;
run;

And I'm still getting results with same values (besides the ones that are 0):

 

AppResults.PNG

Solution
‎11-29-2016 01:03 PM
Super User
Posts: 5,498

Re: Comparing Values with different informats

Posted in reply to JediApprentice

Try adding another variable:

 

difference = ApprovedMemberPay - approvedPatientPayAmount;

 

I suspect the values will be tiny, like 1E-15.  If that turns out to be true, it will be helpful information for you to decide on the next step.

Frequent Contributor
Posts: 123

Re: Comparing Values with different informats

Posted in reply to Astounding

@Astounding You're right, they turned out to be very small values; 8.88E-16, -5.32E-15...

Super User
Posts: 7,762

Re: Comparing Values with different informats

Posted in reply to JediApprentice

Use the round() function to discard the small fractional values. These tiny values are artifacts of the way SAS stores and computes numerical values.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 221 views
  • 2 likes
  • 4 in conversation