Most likely the issue is using INDEX() when you actually want INDEXW() or better still the FINDW() function because of the TRIME modifier it allows.
data have;
input nam_1 :$50. iso_a2 :$2. ;
cards;
Ham AL
Harriet AL
Harry AL
Hello AL
Hitachi AL
Hog AL
Hogwarth AL
Holler AL
Hummer AL
;
data want;
set have;
by iso_a2 ;
length short_code $2 list $100 ;
retain list;
if first.iso_a2 then call missing(list);
do index=2 to length(nam_1) until(not found);
short_code=upcase(cats(char(nam_1,1),char(nam_1,index)));
found = findw(list,short_code,',','it');
end;
list=catx(',',list,short_code);
run;
What is it you want to do when you get to something where there is no unique second letter to use?
... View more