Hi,
I think you could define your format like this:
DATA test;
input string: $50.;
datalines;
Pineapple.colour.yellow
Pinenuts.size.small
Apple.fruit.red
Grape.shape.round
Orange.fresh.juice
Mango.raw.pickled
;
RUN;
PROC FORMAT;
Invalue $tester (notsorted)
's/(.*?)(pine|apple)(.*)/$2/i' (regexpe) = _same_ /*non greedy to match pine first*/
's/(.*)(gra)(.*)/$2/i' (regexpe) = _same_
's/[^\.]*\.[^\.]*\.(.*)/$1/i' (regexpe) = _same_
Other=_error_
;
run;
DATA test2;
SET test;
string2=input(string,$tester.);
RUN;
... View more