BookmarkSubscribeRSS Feed
Steelers_In_DC
Barite | Level 11

I am comparing two large datasets that should be identical.  I was just told by the client that they want an output that will only be generated if there are exceptions.  There are 66 variables but there could be more in other similar tests, there are character and numeric variables.  The only thing I can think of is to merge on id and date and check each variable.  If I add Prev_ to the variable name and then merge I can check each one but that seems horrible.  The variable names are not consistent in any way.  I'm not sure what additional information to put, just looking for any better solutions.

Thanks,

2 REPLIES 2
Rick_SAS
SAS Super FREQ

Can you use PROC COMPARE with a RENAME= option on the COMPARE= data set?

ballardw
Super User

Start with Proc Compare and options nodate novalues. You will get a summary of common variable names with differing characteristics, variables that exist in only one data set, and if the sets are sorted in similar fashion a summary of differing pairs which are marginally useful.

Further step would be using the ID option which specifies variables used to identify the records so you get better matches, and WITH and VAR statements to provide a list variable pairs;

VAR Id date amount;

WITH CustId PurchaseDate PurchaseValue;

would compare values of Id with CustId, date with PurchaseDate and Amount with PurchaseValue.

And if you have similar "candidates" for comparison you do something like

Var Date Date;

With PurchaseDate PaidDate;

It will be an iterative process, so don't expect to get it in one pass. And custom writing your proposed code might take quite a bit longer.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 465 views
  • 0 likes
  • 3 in conversation