0
votes

I'm totally new to SAS so please be patient. :) I have a Data Job that is producing two data sets that contain a field. I need to compare these two data sets and then output only the rows that do not match, but I'm struggling. Is there a way to accomplish this in SAS? I've tried using "Match Codes", but I couldn't get that to work. I also tried "Cluster Diff", but that didn't work either.

What we have been doing is running two SQL queries and then comparing them in Excel and taking the records that do not match.

Any suggestions would be greatly appreciated.

2
What SAS product are you using to achieve this? I ask because Data Management Studio, which used to be DataFlux, has a totally different approach than any other SAS product and from your title and question I assume you are doing it in DMS. - Laurent de Walick
@Laurent de Walick, you are right. I'm using Data Management Studio 2.4. - mack
I'm not really familiar with DMS, but what about first doing a full join using the Data Joining node and then filter on either left value or right value is null using a Data Validation node? - Laurent de Walick

2 Answers

0
votes

You need to use PROC COMPARE for this kind of task.

proc compare  base=<main dataset> compare=<other dataset> outdif out=<output dataset>;
by <id variables?>;
var <variables to compare, or leave this off for all variables>;
run;

That's the basic structure; read the documentation for more details.

0
votes

You could do this in the datastep using merge. The below will give you anything in dataset_A that is not in dataset_B

data output_dataset;
  merge dataset_A (in=a)
        dataset_B (in=b)
        ;
  by <variable>;
  if a and not b;
run;