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!
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.