1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
* Flag cases where last characters are "ESQ" or "ESQ." or variations such as "Esq".
* Ray.

DATA LIST LIST /word(A25).
BEGIN DATA
"Bob Smith, farmer"
"John Allen, Esq"
"John Allen, Esq."
"Billy Joe, MD"
"Batman Esq."
"Batman ESQ.    "
"Ray LevESQue"
END DATA.

Compute flag=ANY(SUBSTR(UPCASE(RTRIM(word)),LENGTH(RTRIM(word))-3.),' ESQ','ESQ.').
* Note in above line INDEX cannot be used because it would flag occurences of ESQ which are not at the end of the field.
EXECUTE.