The CONTAINS operator can be used to look for a user-specified string in a character variable.
Like the LIKE operator, the CONTAINS operator is case-sensitive, and can only be used within a WHERE clause.
While the CONTAINS operator is similar to the INDEX function, it returns a Boolean value rather than the position of the character string.
The two steps below are equivalent.
The CONTAINS keyword can be replaced with the shortcut ? (question mark).
data CHECK;
set SASHELP.ZIPCODE(where=(COUNTYNM contains 'z'));
run;
proc sql;
create table CHECK as
select *
from SASHELP.ZIPCODE
where COUNTYNM ? 'z';
quit;
See the documentation for more information on the WHERE operators.
Thanks to Otterm1 for sharing this tip on sasCommunity.org.