DATA Step, Macro, Functions and more

Identical numeric values are not matching in proc compare

Reply
Super Contributor
Posts: 312

Identical numeric values are not matching in proc compare

Dear,

The following seq values in my data same values in both base and compare data sets. But when I run proc compare in my actual data 

the values are not matched. Please suggest. 

 The length,informat, format in both actual datasets are 8,8.,8. respectively.

If I copy the values into 'one' and 'two' data sets (shown below) and compare the values are matching.

Thank you

Compare results showing:

SAS Output

5.3537E14  5.3537E14      -1999  -3.73E-10
data one;
input seq;
datalines;
5.354E14
;
run;

data two;
input seq;
datalines;
5.354E14
;
run;

proc compare base=one compare=two;
run;

  

Super User
Posts: 6,628

Re: Identical numeric values are not matching in proc compare

Posted in reply to knveraraju91

Try it again?

 

I get an exact match when I run your program.

 

Is your program a simplification of the original circumstances?

Super Contributor
Posts: 312

Re: Identical numeric values are not matching in proc compare

Posted in reply to Astounding

Thank you very much for the reply. 

 

The values are not matching in my actual comparison.

 

But the values are matching if copy the same values into one and two data sets. 

Super User
Posts: 13,298

Re: Identical numeric values are not matching in proc compare

[ Edited ]
Posted in reply to knveraraju91

if you examine the values with a different format such as 24.8 you might very well see a difference. The format will round values to display them within the limits of the stated characters.

 

When you place them into a data set that way you are providing a rounded value that is identical when read so that has no bearing on the values of the variables in the other data set.

 

PROC COMPARE has the CRITERION and METHOD options that will set different rules determining equality.

 

You should show the code you were using to compare the values. There are a number of ways where small differences can be set to be considered equal if needed but depend on the comparison used.

 

Here is an example of two values that are not equal but "appear" equal when a format is applied.

data example;
   x= 12345678910.123;
   y= 12345678910.456;
run;

proc print data=example;
   format x y best8.;
run;

 

PROC Star
Posts: 1,566

Re: Identical numeric values are not matching in proc compare

Posted in reply to knveraraju91

I get the same results that @Astounding got:

 

data one;
input seq;
datalines;
5.354E14
;
run;

data two;
input seq1;
datalines;
5.354E14
;
run;

proc compare base=one compare=two;
VAR seq;
WITH seq1;
run;

SAS Output

 Number of Observations in Common: 1.                                 
      Total Number of Observations Read from WORK.ONE: 1.                  
      Total Number of Observations Read from WORK.TWO: 1.                  
                                                                           
      Number of Observations with Some Compared Variables Unequal: 0.      
      Number of Observations with All Compared Variables Equal: 1.         
                                                                           
      NOTE: No unequal values were found. All values compared are exactly  
            equal.                                                         
                     
Super User
Posts: 23,247

Re: Identical numeric values are not matching in proc compare

Posted in reply to knveraraju91

You can use the FUZZ option, to specify what level of detail you want. Note the results there say the error is really really low, 

-3.73E-10

Which is 0.000000000373. 

 

So you can set FUZZ to mask errors less than 0.01. 

 

proc compare base=one compare=two fuzz=0.01;
run;
Ask a Question
Discussion stats
  • 5 replies
  • 92 views
  • 4 likes
  • 5 in conversation