I tried below code to convert the words to space if the string ends in limited,ltd,plc,sa,inc. But the third record(limited abc) , the abc is converted to a space. Any help is appreciated!
data test;
input string $1-12;
cards;
abc limited
pqr ltd
limited abc
abc sa
abc plc
plc abc
abc inc
;
run;
data want;
set Test;
if prxmatch("/(^.*\binc\b|^.*\blimited\b|^.*\bltd\b|^.*\bsa\b|^.*\bplc\b)/i",string) > 0 then do;
want=prxchange('s/\w+$//',-1,strip(string));
End;
run;