It's a little hard to follow what you're doing - for one thing, you can comment out multiple lines like this to make things easier to read:
/*
Here is a
comment that is
3 lines long. */
Merging / joining on strings (especially when they're just names that are entered freehand) is not ideal as you've discovered, but sometimes that's all you have. You could try using some sort of "fuzzy" merge like this:
https://blogs.sas.com/content/sgf/2021/09/21/fuzzy-matching/
As for the join, I think you will have an easier time assessing with a single LEFT join and then doing some counts on the resulting data:
PROC SQL;
create table want as
select b.permno, a.bobnamesNew, b.company_name_header, a.bobnamesOriginal
from
work.Temp A
LEFT JOIN
(select distinct permno, company_name_header from names.CRSPnames) B
on a.bobnamesNew=b.company_name_header;
title "# distinct bobNames without a match in CRSP";
select count(distinct a.bobnamesNew) from WANT where missing(permno);
title;
QUIT;
Again, you're going to either have to try a fuzzy merge or, more likely, actually manually correct the bobnames. If there are just things like differences in case, whitespace, special characters, etc., then you probably could make this more automated, but you'd have to provide some examples here in order for people to help.
I have to say that without actual example data sets and how this was actually done
/* Bobnamesnew is the company name after I clean the name to increase chances of */ /* finding a match in the CSRP database. */
that I might suspect the "cleaning" step of being part of a problem. I have seen some "cleaning" that created matches for other values in a data set. This may happen if you have original names that are related, such as subsidiaries. Which may have different PERMNO but similar names...
Is there a reason there is no code showing attempted matches or searches using the PERMNO?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.
Find more tutorials on the SAS Users YouTube channel.