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
Lapis Lazuli | Level 10

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! 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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