Editor's Note: The CONTAINS operator is valid in a WHERE clause, not an IF statement. As shown by @deleted_user, using the INDEX or the FIND functions provide the closest equivalent. There is also a SAS Note, Sample 43303, that discusses this.
Assuming this is data step code, either one of the find() or index() functions should produce the desired result:
if index((trim(put(Name,test30.)) , 'RICHARD NU');
See the documentation for more details.
Jonathan
> if (trim(put(Name,test30.)) not contains ('RICHARD
> NU')) ;
>
> est30. is a format from format dataset.
>
> When I am trying as above I am getting error as
> Syntax error, expecting one of the following: <, <=,
> =, >, >=, EQ, GE, GT, LE,
> LT, NE, NG, NL, ^=, ~=.
> t to use NE . I should use 'not contains' . Is it
> possible with 'not contains'? Thanks .
Editor's Note: The CONTAINS operator is valid in a WHERE clause, not an IF statement. As shown by @deleted_user, using the INDEX or the FIND functions provide the closest equivalent. There is also a SAS Note, Sample 43303, that discusses this.
Assuming this is data step code, either one of the find() or index() functions should produce the desired result:
if index((trim(put(Name,test30.)) , 'RICHARD NU');
See the documentation for more details.
Jonathan
> if (trim(put(Name,test30.)) not contains ('RICHARD
> NU')) ;
>
> est30. is a format from format dataset.
>
> When I am trying as above I am getting error as
> Syntax error, expecting one of the following: <, <=,
> =, >, >=, EQ, GE, GT, LE,
> LT, NE, NG, NL, ^=, ~=.
> t to use NE . I should use 'not contains' . Is it
> possible with 'not contains'? Thanks .
I use NOT CONTAINS within SAS Miner. I often have to consider the data structure. If the data set is unstructured, like a paragraph of text, NOT CONTAINS often provides you a little more freedom compared to NE to parse the text.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.