Pearl Regular Expressions are probably the easiest, e.g.:
data test;
text="AB.name = dsn.pname and AB.ID = dsn.varID and AB.custid=dsn.customerid";
prxid=prxparse('/(?<=\bdsn\.)\S*/i');
start=1;
pos=0;
len=0;
do until(0);
call prxnext(prxid,start,-1,text,pos,len);
if len=0 then leave;
outvar=substr(text,pos,len);
output;
end;
run;
An explanation of the search string in PRXPARSE: "(?<=\bdsn\.)" is a look-behind assertion: it has to be there but is not included in the output. The meaning is a word boundary (\b) plus the text "dsn." ("." has to be escaped with a "\"). After that comes "\S*", meaning zero or more non whitespace characters, which is the string you are looking for. the final "i" just means that the search is case independent, the search will find "DSN." as well as "dsn.".
... View more