You could use pattern matching like this: data have; input Keyword :&$80. Impressions Clicks; datalines; [sale on gas grills] 10 2 "Gas grill sales" 0 0 green egg sale grills 420 336 ; data want; set have; beg = prxmatch('/^[\["]?\s*sale(s)?\b/io', Keyword)>0; mid = prxmatch('/\w+.*\b\bsale(s)?\b.*\w+/io',Keyword)>0; end = prxmatch('/\w+.*\bsale(s)?\s*["\]]?$/io',trim(Keyword))>0; run; proc print data=want noobs; run; Whatever solution you choose, it should be tested with more examples. PG
... View more