BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

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;

  

5 REPLIES 5
Astounding
PROC Star

Try it again?

 

I get an exact match when I run your program.

 

Is your program a simplification of the original circumstances?

knveraraju91
Barite | Level 11

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. 

ballardw
Super User

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;

 

novinosrin
Tourmaline | Level 20

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.                                                         
                     
Reeza
Super User

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;

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!

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.

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
  • 5 replies
  • 5793 views
  • 4 likes
  • 5 in conversation