Comparing two columns

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

Comparing two columns

Ok this is probably pretty simple for a lot of you.

I have two datasets....one called Stuff and the other called Stuff2.

They both have a column called Site with 95% of the same data in it. However Stuff2 has about 200 fewer records than Stuff. I would like to see which records are in Stuff and not in Stuff2 using Site as the key. Is there an easy way to do this? Thanks in advance.



Accepted Solutions
Solution
‎02-24-2014 11:08 AM
Super User
Super User
Posts: 7,970

Re: Comparing two columns

Datastep:

Sort stuff by Site

Sort stuff2 by Site

data miss_stuff miss_stuff2;

  merge stuff (in=a) stuff2 (in=b);

  if a and not b then output miss_stuff2;

  if b and not a then output miss_stuff;

run;

View solution in original post


All Replies
Solution
‎02-24-2014 11:08 AM
Super User
Super User
Posts: 7,970

Re: Comparing two columns

Datastep:

Sort stuff by Site

Sort stuff2 by Site

data miss_stuff miss_stuff2;

  merge stuff (in=a) stuff2 (in=b);

  if a and not b then output miss_stuff2;

  if b and not a then output miss_stuff;

run;

Occasional Contributor
Posts: 9

Re: Comparing two columns

Hmmm...doesn't seem to be working....the data set I'd expect to have the missing values from Stuff2 has 0 observations. Any ideas?

Occasional Contributor
Posts: 9

Re: Comparing two columns

Actually,

It was my mistake....it works. Thank you much!

🔒 This topic is solved and locked.

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

Discussion stats
  • 3 replies
  • 176 views
  • 0 likes
  • 2 in conversation