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!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.