Hi @alw12194
The following code splits the input string into elements, that are "anything" separated by blanks, so the elements can be processed one by one and omitted according to the criterias. Then only elements that passes the tests are included in the output string. It might not be elegant code, but is makes it easy to experiment with different criterias.
The code discards elements consisting of numbers only + elements that are stand-alone hyphens. It seems that hyphens in Airport names are not surrounded by blanks, so the will not be omitted.
data have;
infile datalines truncover;
input name $char100.;
datalines;
12345 - hartsfield airport
hartsfield airport - 12345
hartsfield airport
;
data want (drop=element i err:);
set have;
length element newname $100;
* Split name in elements;
do i = 1 to countw(name,' ');
element = scan(name,i,' ');
* Define conditions for omitting elements;
err1 = not notdigit(trim(element));
err2 = (element = '-');
* Add accepted elements to newname;
if max(err1,err2) = 0 then newname = catx(' ',newname,element);
end;
run;
... View more