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?
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!
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.