BookmarkSubscribeRSS Feed
Filipvdr
Pyrite | Level 9

Hello,

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?

Thanks,

Filip

3 REPLIES 3
Astounding
PROC Star

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.

ballardw
Super User

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.


Reeza
Super User

#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...

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 904 views
  • 0 likes
  • 4 in conversation