Desktop productivity for business analysts and programmers

NOT LIKE OPERATOR DOES NOT WORK WITH A LIST

Accepted Solution Solved
Reply
Contributor
Posts: 68
Accepted Solution

NOT LIKE OPERATOR DOES NOT WORK WITH A LIST

I Would like to remove supplies from  file. below code does not work. it works only for one supply. when combined   , it does not remove  .

any other way to remove all at once.

AND  (A.PROD_1_DESC NOT LIKE 'ADAPTER%' OR A.PROD_1_DESC NOT LIKE 'AUVI-Q%'

OR A.PROD_1_DESC NOT LIKE 'AVOSTARTGRIP%'

OR A.PROD_1_DESC NOT LIKE 'CATH++%' OR A.PROD_1_DESC NOT LIKE 'CLAVE%'

OR A.PROD_1_DESC NOT LIKE 'CONNECTOR%' OR A.PROD_1_DESC NOT LIKE 'CRONO SYRINGE%'

OR A.PROD_1_DESC NOT LIKE 'DRESSING%' OR A.PROD_1_DESC NOT LIKE  'FILTER%'

OR A.PROD_1_DESC NOT LIKE 'GRIPPER%' OR A.PROD_1_DESC NOT LIKE 'HUBER%'

 

Please help.

Thanks


Accepted Solutions
Solution
3 weeks ago
Super User
Posts: 6,622

Re: NOT LIKE OPERATOR DOES NOT WORK WITH A LIST

Your logic is incorrect.  Change OR to AND.  

View solution in original post


All Replies
Super User
Posts: 13,283

Re: NOT LIKE OPERATOR DOES NOT WORK WITH A LIST

You could include all of the code, an example data set that demonstrates the behavior and what you expect the result to be. Best is to post example data in the form of a data step so we can actually test code against your data and to post all code in a code box opened with the forum {I} icon.

 

When you have "something and (<a bunch of OR comparisons>) the part before the AND is significant as well.

 

Solution
3 weeks ago
Super User
Posts: 6,622

Re: NOT LIKE OPERATOR DOES NOT WORK WITH A LIST

Your logic is incorrect.  Change OR to AND.  

PROC Star
Posts: 1,286

Re: NOT LIKE OPERATOR DOES NOT WORK WITH A LIST

Posted in reply to Astounding

ANDs and ORs with NOTs are tricky. If you think about it, with

 

VAR1 NOT LIKE 'A' OR VAR1 NOT LIKE 'B'

 

if Var1 is 'A', it is not like 'B'. If it's 'B', it's not like 'A'. So you always pass the test.

 

As suggested above, change OR to AND, or use the structure

 

NOT (LIKE 'A' OR LIKE 'B' OR LIKE 'C')

 

Tom

 

Contributor
Posts: 68

Re: NOT LIKE OPERATOR DOES NOT WORK WITH A LIST

Thank you all very much !!!!. Now I understand how this works.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 145 views
  • 2 likes
  • 4 in conversation