BookmarkSubscribeRSS Feed
jackmelbourne
Fluorite | Level 6

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

2 REPLIES 2
collinelliot
Barite | Level 11

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; 
collinelliot
Barite | Level 11

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 2 replies
  • 1782 views
  • 0 likes
  • 2 in conversation