A not to complex regular expression and call prxnext can solve the problem: data work.have;
length lot $ 100;
input;
lot = trim(_infile_);
datalines;
@nice#Greatwork@fake
very nice portal ncs
Good portal @hatsoff
;
run;
data work.want;
set work.have;
length
word $ 100
rx start p l 8
;
retain rx;
if _n_ = 1 then do;
rx= prxparse('/([@#]\w+)/i');
end;
start = 1;
call prxnext(rx, start, -1, lot, p, l);
do while (p > 0);
word = substr(lot, p, l);
output;
call prxnext(rx, start, -1, lot, p, l);
end;
if missing(word) then do;
word = 'null';
output;
end;
keep word;
run;
... View more