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

I want to search for list of drugs in oracle database. can I list all the drugs in proc sql in where clause as below?

 WHERE (
(A.PRODUCT_DESC_1 CONTAINS ('ARIPIPRAZOLE',' ASENAPINE',BREXPIPRAZOLE)

 

I got  ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, )

 

Please help

 

Thanks,

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

proc sql;
  select *
  from   <YOUR_TABLE> A
  where  A.PRODUCT_DESC_1 in ("ARIPIPRAZOLE","ASENAPINE","BREXPIPRAZOLE");
quit;

View solution in original post

8 REPLIES 8
LinusH
Tourmaline | Level 20

CONTAINS doesn't support a list as argument. You need to combine them with OR.

Data never sleeps
avatar
Fluorite | Level 6
With below code got error again:
ERROR: CONTAINS operator requires character operands.
A.PRODUCT_DESC_1 CONTAINS ('ARIPIPRAZOLE' or 'ASENAPINE' or 'BREXPIPRAZOLE').
Anything wrong?
Reeza
Super User

The syntax is incorrect, you need a contains for each argument, definitely a bit cumbersome. 

 

A.PRODUCT_DESC_1 CONTAINS ('ARIPIPRAZOLE') 
                                 or CONTAINS ('ASENAPINE')
                                 or ...
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

proc sql;
  select *
  from   <YOUR_TABLE> A
  where  A.PRODUCT_DESC_1 in ("ARIPIPRAZOLE","ASENAPINE","BREXPIPRAZOLE");
quit;
avatar
Fluorite | Level 6
I find variations in drug name like ARIPIPRAZOLE++, ARIPIPRAZOLE
Contains brings both. I will go with contains
WHERE t1.PRODUCT_DESC_1 CONTAINS ('ARIPIPRAZOLE')
OR t1.PRODUCT_DESC_1 CONTAINS ('CLOZAPINE');
This code worked .
Thank you so much!!
RW9
Diamond | Level 26 RW9
Diamond | Level 26

There are other constructs which may help you:

where XYZ like "*ABC*";

will give you all which contain the string ABC. 

 

avatar
Fluorite | Level 6
I cannot list all drugs using like, right?
WHERE t1.PRODUCT_DESC_1 like ('*ARIPIPRAZOLE*','*ASENAPINE*')

RW9
Diamond | Level 26 RW9
Diamond | Level 26

No, like is used for pattern matching.  Why are you looking for drug names by the way?  Should you data not be encoded with WHODrug codes - that is not only safer (you don't miss ones) its simpler as well because you can use higher level terms to bring out groups of related drugs.  Also its standard in the industry. 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 8 replies
  • 1954 views
  • 1 like
  • 4 in conversation