BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
cf8261a
Calcite | Level 5

I am trying to run a PROC SQL statement with a contains statement, but the log keeps saying:

 

ERROR: Function CONTAINS could not be located.

 

Is contains not a valid function that can be used in proc sql steps?

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star
proc sql;

select Reason from Active where Reason contains 'opportunity';

run; quit;

CONTAINS isn't a function.

View solution in original post

7 REPLIES 7
SASKiwi
PROC Star

Posting an error message without the code that caused it leaves us guessing what you are doing. Please post the offending code.

cf8261a
Calcite | Level 5

proc sql;

select Reason from Active where contains(Reason, 'opportunity');

run; quit;

 

ERROR: Function CONTAINS could not be located.

 

Here is that code snippet

 

SASKiwi
PROC Star
proc sql;

select Reason from Active where Reason contains 'opportunity';

run; quit;

CONTAINS isn't a function.

whymath
Barite | Level 11

And you can replace it by "?":

proc sql;
  select Reason from Active where Reason ? 'opportunity';
quit;
AMSAS
SAS Super FREQ

To add some context to @SASKiwi reply

The syntax @cf8261a had for contains makes SAS think you are referring to a function (e.g. function_name(argument#1,..., argument#n)

The error message is correct "contains" is not a function it is the CONTAINS Operator and the correct syntax is:

sql_expression <NOT> CONTAINS  sql_expression 

Reeza
Super User
The FIND or INDEX function can be used in place of CONTAINS or you can fix the syntax as noted by @SASKiwi
cf8261a
Calcite | Level 5

Thank you everyone for all of the helpful comments! 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2512 views
  • 0 likes
  • 5 in conversation