BookmarkSubscribeRSS Feed
Sandeep77
Lapis Lazuli | Level 10

Hi Experts,

I want to compare two huge data set with lot of rows and columns. With proc compare can I compare the entire data set or I have to select few columns and then compare? Also, is there a link where I can check how to write the proc compare statement?

3 REPLIES 3
Quentin
Super User

Yes, PROC COMPARE can compare entire datasets. 

 

See the documentation:

 

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1nwxbchh5hpu1n1h28kmici2awd.htm

 

proc compare base=dataset1 compare=dataset2;
  id PatientID;  *Almost always you want an ID statement, otherwise it will compare by row;
run;
  

 

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
kleelasiva9
Obsidian | Level 7

Q: With proc compare can I compare the entire data set or I have to select few columns and then compare?

Ans: Both, but by default proc compare compares entire dataset. Using Var statement restricts the comparison of the values of variables to the ones named in the VAR statement.

 

Q: Also, is there a link where I can check how to write the proc compare statement?

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1xrf09nbjnxjzn1kdmbcajf1s1v.htm 

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n0c1y14wyd3u7yn1dmfcpaejllsn.htm 

ballardw
Super User

@Sandeep77 wrote:

Hi Experts,

I want to compare two huge data set with lot of rows and columns. With proc compare can I compare the entire data set or I have to select few columns and then compare? Also, is there a link where I can check how to write the proc compare statement?


If you have any doubt about the order of data you may need to consider sorting by variables at sufficient level to identify unique records. If the data is identical other than sort order you will get many mismatches because record 1 is compared with record 1, 2 with 2, 3 with 3 by default.

 

 

 

 

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 550 views
  • 3 likes
  • 4 in conversation