The possibilities are endless... You can account for hyphenated names and firstnames easily, but frankly I don't even know what's what in "B. Evan Bayh, III". If such "names" are rare, you might be better sending them to a separate table and treating them by hand...
Data test;
input id fullname $64.;
datalines;
1 Michael R. Boyce
2 James G. Brocksmith, Jr.
3 Gerald F. Fitzgerald, Jr.
4 Norman R. Bobins, BS, MBA
5 Peter Pace, USMC, Ret.
6 Ryan, Norman A.
7 Anne Newman Foreman
8 Michael R.S. Boyce
9 Ryan, Norman A., BS
10 Lavizzo-Mourey, Evans
11 B. Evan Bayh, III
;
data want except(keep=id fullname);
length firstName lastName $20 initials $6;
if not prxId1 then prxId1 + prxParse("/^([\w-]+)\s+(([A-Z]\.)*\s*)([^,]+)/");
if not prxId2 then prxId2 + prxParse("/^([\w-]+),\s*([\w-]+)\s+(([A-Z]\.)*)/");
set test;
if prxMatch(prxId1, fullname) then do;
firstName = prxPosn(prxId1, 1, fullname);
initials = prxPosn(prxId1, 2, fullname);
lastName = prxPosn(prxId1, 4, fullname);
output want;
end;
else if prxMatch(prxId2, fullname) then do;
firstName = prxPosn(prxId2, 2, fullname);
initials = prxPosn(prxId2, 3, fullname);
lastName = prxPosn(prxId2, 1, fullname);
output want;
end;
else output except;
drop prxId: ;
run;
title "Matched names";
proc print data=want noobs; run;
title "Unmatched names";
proc print data=except noobs; run;
... View more