SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
AieuYuhara
Fluorite | Level 6

Hi all, 

 

I performed PROC COMPARE to a dataset, as purpose of UAT, I have to check the accuracy of the data. In the first stage, I include the data that we have and saw A LOT of discrepancies. Hence, I tried to used same dataset which been used to upload into the server, then performed PROC COMPARE, I found out, IT STILL HAVE UNEQUAL VALUES.

 

Through eyeball checking, the base and compare data set, does HAVE SAME VALUES. But when performing PROC COMPARE, I realized that the variables in Base data set has been rounded to a number which I dont know about.

 

As an example:

Base: 0.38459348 ------ Compare:  0.38459348

Output >> 0.3846 base ---- 0.38459348 >> Different: -0.00000652

 

How can I cater this problem? I want the base dataset to be read as it is, without rounding up any values on the Base dataset

 

Kindly help. Really appreciate your help! 

 

 

5 REPLIES 5
ChrisNZ
Tourmaline | Level 20

Proc compare does not round. The data is different.

 

One way to do what you want may be to compare within say a thousandth.

 

Add options: method=absolute criterion=0.001

AieuYuhara
Fluorite | Level 6

Tried before, and still couldn't capture that the data is actually the same. The problem only appear to the numbers in the Base dataset, which is exactly the same as the one I uploaded to compare with. Logically, it should be an equal values for all fields. 

 

Plus, I noticed that in the output, it only have 4 decimal points max whereas my data has 8 decimal points. Any other way to cater this difference? Like letting the base data set read the way it is, which is 8 decimal points instead of just 4..?

ChrisNZ
Tourmaline | Level 20
1. Did you try these 2 options? They will solve the issue with the data example you showed.
2. Are the formats the same?
3. Just checking. They are numeric variables right?
AieuYuhara
Fluorite | Level 6

1. Yes. Below is the example output I got:

Base ABCCompare ABCDiff.
0.2540.25396771-3.229E-05
0.12340.123405895.89E-05

 

As noticed, the base ABC value is rounded. From eyeball checking, the base table ABC have exactly same value and same format as Compare ABC. But when we use to compare between both table, it only compares 4 decimal places (from its actual 8 decimal points) vs 8 decimal values (as in the compare table). It didnt round up any value in compare table, but it does round up the value in the base table.

 

2. Yes. Format is the same. Numeric BEST12.

3. Yes. Numeric Variable. 

ChrisNZ
Tourmaline | Level 20

You are doing something wrong. The comparison works fine here.

 

data T1;
  X=0.1234;
data T2;
  X=0.12340589;
proc compare data=T1 compare=T2 method=absolute criterion=0.001;
run; 

 

                                                                                               
                                   Values Comparison Summary                                   
                                                                                               
                Number of Variables Compared with All Observations Equal: 1.                   
                Number of Variables Compared with Some Observations Unequal: 0.                
                Total Number of Values which Compare Unequal: 0.                               
                Total Number of Values not EXACTLY Equal: 1.                                   
                Maximum Difference: 0.00000589.  

 

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 3849 views
  • 0 likes
  • 2 in conversation