Hello -I am attempting to compare a large number of numeric and character across multiple datasets. I have coded the numeric portion, but am looking for a way to include both character and numeric variables. In my code below, the &list includes only numeric variables. I imagine I could use a compare function for character, but I'm not sure on the best route to take. Here is my code:
welcome to the world of comparing differences. Sometimes just using Proc compare works better for me that using a SQL statement for comparing. Other times I use the X commands to do compares when I need to do that for SAS datasets I create a temporary text version of the SAS data and call FC for comparing.
One suggestion would be to get the process to work without macros for comparing the character strings.
then re-macro it after the process works for a few different type of compares. -- Steady as she goes --
I would begin with:
case (when a.&var ne b.&var then cat(a.&var, '*' , b.&var else ' ') as &var._diff
There aren't a whole lot of rules when it comes to a character variable being different. So this will capture the differences.
An important question to consider: will there always be exactly 1 observation per ID in both data sets?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.