hi ... fyi, this might not apply with your current data set but ...
sometimes there's a difference between looking for a WORD and
looking for a STRING of characters
when looking for a word, it's safer to use INDEXW
since the search string might be embedded in the
text of another word
also, case might be an issue, so ...
[pre]
data test;
input text $20.;
datalines;
Mary is from Maryland
Scott is from Maryland
mary is from Maryland
;
run;
data mary;
set test;
mary1 = index (text,'mary') ne 0;
mary2 = indexw(text,'mary') ne 0;
mary3 = index(upcase(text),'MARY') ne 0;
mary4 = indexw(upcase(text),'MARY') ne 0;
run;
Obs text mary1 mary2 mary3 mary4
1 Mary is from Maryland 0 0 1 1
2 Scott is from Maryland 0 0 1 0
3 mary is from Maryland 1 1 1 1
[/pre]
if I'm looking for any observation with the person Mary
(regardless of case), only the variable MARY4 works with
this data set