Output of Proc Compare get only differences

Accepted Solution Solved
Reply
Contributor
Posts: 42
Accepted Solution

Output of Proc Compare get only differences

[ Edited ]

Hi All,

 

I want to see only records with differences included in my output with the structure shown below:

 

_TYPE_

obs

var1

var2

var3

var4

BASE

1

34

115003481

1214

48

COMPARE

1

34

115003481

1214

48

DIF

1

34

115003481

1214

48

 

The program used was:

 

 

proc compare base=F.&MATCH1 compare=F.&MATCH2
  OUT=F.&DIFF 
	outbase
	outcomp
	outdif
;
  id var1 var2 var3 var4 ;
run;
                   Number of Observations in Common: 4083722.                                                               
                           Number of Observations in F.MATCH1 but not in F.MATCH2: 158.                           
                           Total Number of Observations Read from F.MATCH1: 4083722.                                        
                           Total Number of Observations Read from F.MATCH2: 4083880.                                      
                                                                                                                                    
                           Number of Observations with Some Compared Variables Unequal: 2.                                          
                           Number of Observations with All Compared Variables Equal: 4083720.                                       
                                                                                                                                    
                                                                                                                                    
                                                     Values Comparison Summary                                                      
                                                                                                                                    
                                  Number of Variables Compared with All Observations Equal: 173.                                    
                                  Number of Variables Compared with Some Observations Unequal: 2.                                   
                                  Number of Variables with Missing Value Differences: 2.                                            
                                  Total Number of Values which Compare Unequal: 2.                                                  
                                  Maximum Difference: 0.      

 

Why  my output file is generating more than 12 millions of observations -including that are exactly equals in both files- ??, I only want on my ouput file with unequals observations, like this:

 

                        Number of Observations with Some Compared Variables Unequal: 2.  

 

Thanks in advance and regards,

 

JC

 


Accepted Solutions
Solution
‎03-28-2017 04:15 PM
Super User
Posts: 17,840

Re: Output of Proc Compare get only differences

[ Edited ]

Looking at the documenation (or below in red) you can see why you're getting the behaviour you've described. You can fix this by specifying the OUTNOEQUAL option instead. See the code below. 

 

Documentation for PROC COMPARE:

 

 

 

 
OUTBASE

writes an observation for each observation in the base data set.

OUTCOMP

writes an observation for each observation in the comparison data set

OUTDIF

writes an observation to the output data set for each pair of matching observations.

 
OUTNOEQUAL

suppresses the writing of observations when all values are equal.

 

*sample data to check;
data class;
set sashelp.class;

if age=12 then weight=50;
run;

*proc compare test;
proc compare data=class compare=sashelp.class out=check outnoequal ;
id name;
run;

*results;
proc print data=check;run;

 

 

View solution in original post


All Replies
Solution
‎03-28-2017 04:15 PM
Super User
Posts: 17,840

Re: Output of Proc Compare get only differences

[ Edited ]

Looking at the documenation (or below in red) you can see why you're getting the behaviour you've described. You can fix this by specifying the OUTNOEQUAL option instead. See the code below. 

 

Documentation for PROC COMPARE:

 

 

 

 
OUTBASE

writes an observation for each observation in the base data set.

OUTCOMP

writes an observation for each observation in the comparison data set

OUTDIF

writes an observation to the output data set for each pair of matching observations.

 
OUTNOEQUAL

suppresses the writing of observations when all values are equal.

 

*sample data to check;
data class;
set sashelp.class;

if age=12 then weight=50;
run;

*proc compare test;
proc compare data=class compare=sashelp.class out=check outnoequal ;
id name;
run;

*results;
proc print data=check;run;

 

 
Contributor
Posts: 42

Re: Output of Proc Compare get only differences

Thanks man!!

 

It worked for me !!

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 1066 views
  • 0 likes
  • 2 in conversation