The SAS Output Delivery System and reporting techniques

Compare program.

Regular Contributor
Posts: 246

Compare program.


I have to compare datasetA_Version1 with datasetA_Version2

V2 has more data than V1. There is NO unique identifier in this dataset.

The program should list:

  1. - The data that are on the first one but that are no longer on the second one
  2. - The discrepancy between the two datasets but only for the data that are on both dataset
  3. - Difference in number of rows.

So i can handle number 3.

But how can you compare 2 datasets without this unique identifier? Can you use proc compare herefore?



Super User
Posts: 6,785

Re: Compare program.

This can't be done, unless the additional observations appear at the end of one of the data sets.  PROC COMPARE without a BY statements compares the first observation in one data set to the first observation in the other, then the second observation in the first data set to the second observation in the other.

A good rule of thumb to use:  if you had all the data printed out on paper, could you find the differences?  If the answer is "no", then SAS won't be able to either.

Super User
Posts: 13,583

Re: Compare program.

Is there a combination of variables is likely to identify records uniquely? If so you can try sorting both sets by those variables and then using Proc Compare. The default behavior compares the records by order in the data sets if no BY statement is used.

Super User
Posts: 23,776

Re: Compare program.

#1 - Look up the NOT EXISTS in sql to find records that aren't in 2 but are in 1.

#2 - I don't see how you can identify this at all if you don't have an identifier. You could only identify records in both that were identical, but not ones that had changed somehow.

#3 - That's easily done...

Ask a Question
Discussion stats
  • 3 replies
  • 4 in conversation