I am fairly new to SAS and I have 2 queries that I am trying to merge together and I'm joining by a full outer join. The names are almost the same except 1 set of data has additional space and parentheses next to the name. So, the code is not finding all of the names:
How would I edit the code below to shorten the 'Edited Name' to shorten it if it has a space and parentheses so that they will match better. There is another item I can match on which is the SerID but issue is when I add this in the count distinct messes up so I'm trying to figure out if either I can join on data that isn't in the table or join on a name that sort of matches and will if edited in the formula below.
PROC SQL;
CREATE TABLE WORK.TEST AS
SELECT DISTINCT t1.'Edited Name'n,
t2.'N_DISTINCT_of_SerID'n,
t1.'N_DISTINCT_of_OLH: SupID'n
FROM WORK.TEST t1
FULL JOIN WORK.QUERY_FOR_TEST t2 ON (t1.'Edited Name'n = t2.'OrigName'n)
ORDER BY t1.'N_DISTINCT_of_OLH: SupID'n DESC;
QUIT;
How about:
on compress(t1.'Edited Name'n,"( )") = compress(t2.'OrigName'n,"( )")
the second argument to compress() function means "delete all spaces and parenthesis".
Bart
Where would I add this in the code please?
You just replace your ON condition in your posted example with @yabwon 's.
Removing parentheses is easy, the Compress function will do that. The question is where is the extra space and would we recognize it as such?
You should provide examples.
And if the "count" gets messed up when you have another identification variable then perhaps you don't want to match on only the name as names are unlikely to be unique in any largish real world source, especially if only looking at a first and last name. How do you know that possibly duplicated names are not different people if not looking at other information?
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.