If all you're looking for is to keep a single variable list of matching names, you can do something simple like this:
DATA work.matches;
KEEP Name1;
MERGE work.table1 work.table2;
IF Name1 = Name2;
RUN;
If you're looking for something a little fancier like a fuzzy match where people with different first names but similar last names match as well, you can try a couple of approaches mentioned in this blog post. Here's a sample of one of the methods that you can run now, if you'd like to:
DATA work.table1;
LENGTH Name1 $ 50;
INFILE datalines DSD;
INPUT Name1 $;
DATALINES;
JOSE MANUEL
YULISA PEREZ
JULIO CESAR VALENTIN
SHEILA DE LA ROSA
CHRISTIAN RODRIGUEZ
;
RUN;
DATA work.table2;
LENGTH Name2 $ 50;
INFILE datalines DSD;
INPUT Name2 $;
DATALINES;
JOSE MANUEL
YULISA PEREZ
JULIO CESAR ALMANZAR
SUGELY DE LA ROSA
CHRISITAN QUEZADA
;
RUN;
DATA work.compare;
MERGE work.table1 work.table2;
result1 = SPEDIS(Name1, Name2);
result2 = SPEDIS(Name2, Name1);
result = MEAN(result1, result2);
RUN;
PROC PRINT;
RUN;
I created two tables with you data in them. Then used a MERGE to smash them together, and took advantage of the SPEDIS function to calculate the offset between the names. I swapped the order of the names, recalculated, and averaged just because the length of the first argument changes the final result. Averaging might keep it more consistent if the two names are vastly different lengths. This could still work if you're trying to find only full matches-- just look for any row whose result value = 0;
... View more