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?
proc sql;
select Reason from Active where Reason contains 'opportunity';
run; quit;
CONTAINS isn't a function.
Posting an error message without the code that caused it leaves us guessing what you are doing. Please post the offending code.
proc sql;
select Reason from Active where contains(Reason, 'opportunity');
run; quit;
ERROR: Function CONTAINS could not be located.
Here is that code snippet
proc sql;
select Reason from Active where Reason contains 'opportunity';
run; quit;
CONTAINS isn't a function.
And you can replace it by "?":
proc sql;
select Reason from Active where Reason ? 'opportunity';
quit;
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
Thank you everyone for all of the helpful comments!
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.