Hi @R_Auger,
The 'e' modifier of the FINDW function in conjunction with absolute differences of word positions could be useful to implement something similar to the proximity term NEAR in MS SQL.
Example:
data have;
input n text $50.;
cards;
1 Apple Granny Green
2 Apple Spartan Red
3 Apple Jazz Red
4 Apple Yellow Delicious
5 apple cool Jazz Juicy Dark Red Fruit
6 Apple cool Juicy Dark red Fruit
7 big red super fresh apple
8 red really red super fresh apple
;
proc sql;
create table want(drop=_:) as
select *, findw(text,'apple', ' ', 'ei') as _p1,
findw(text,'red', ' ', 'ei') as _p2
from have
having _p1 & _p2 & abs(_p1-_p2)<5;
quit;
Result:
n text
2 Apple Spartan Red
3 Apple Jazz Red
6 Apple cool Juicy Dark red Fruit
7 big red super fresh apple
Item 8 shows the limitation of FINDW, though: It finds only the first occurrence of a word so that duplicates could be a problem. Here, _p1=6 and _p2=1 violate the proximity condition.
... View more