DATA Step, Macro, Functions and more

Checking if two datasets are identical

Reply
Occasional Contributor
Posts: 11

Checking if two datasets are identical

Dear All,

 

I was wondering if there was any way to check if two datasets are the same? For example, I want to check if set 1 and set2 are identical. In this case they wouldn't be. Also, it's for a much bigger dataset if that makes any difference.

 

 

data set1;
   input Name :$upcase4. Age Net Reg Loss;
   cards;home 300 200 50     .
home 100 80   .     5
TDR  80  75   .     3
TDR  70   .   5     .;;;;
   run;

data set2;
   input Name :$upcase4. Age Net Reg Loss;
   cards;home 300 200 50     .
home 100 80   .     6
TDR  80  75   .     3
TDR  70   .   5     .;;;;
   run;

 Thank you very much in advance!

 

Kind regards,

Jack

PROC Star
Posts: 307

Re: Checking if two datasets are identical

Posted in reply to jackmelbourne

PROC COMPARE should do what you want.

 

data set1;
   input Name :$upcase4. Age Net Reg Loss;
   cards;
home 300 200 50     .
home 100 80   .     5
TDR  80  75   .     3
TDR  70   .   5     .
;;;;

data set2;
   input Name :$upcase4. Age Net Reg Loss;
   cards;
home 300 200 50     .
home 100 80   .     6
TDR  80  75   .     3
TDR  70   .   5     .
;;;;
  
proc compare data = set1 compare = set2;
run; 
PROC Star
Posts: 307

Re: Checking if two datasets are identical

Posted in reply to collinelliot

Note that it can be used with by groups as well.

Ask a Question
Discussion stats
  • 2 replies
  • 154 views
  • 0 likes
  • 2 in conversation