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

Hi everyone,

 

Can you help me on how to use not like operator in a case when statement. 

 

 case when ConsumerNumber NOT IN (4* or H* or M* or N* or Q* or R*) then 'Not Selected' Else 'Selected ' end as selectionresult

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21
case when first(ConsumerNumber) IN ("4", "H", "M", "N", "Q", "R") then 'Selected' Else 'Not Selected ' end as selectionresult
PG

View solution in original post

3 REPLIES 3
ballardw
Super User

can you show the LOG you get when running that code? Copy the entire proc step with messages and paste into a code box opened on the forum with the </> icon.

Divya12
Calcite | Level 5
CODE -
proc sql;
create table method as
select distinct (methodofpayment) as consumernumber ,
case when ((METHODOFPAYMENT) not like "4%") then 'not selected'
when ((METHODOFPAYMENT) not like "H%") then 'not selected'
when ((METHODOFPAYMENT) not like "M%") then 'not selected'
when ((METHODOFPAYMENT) not like "N%") then 'not selected'
when ((METHODOFPAYMENT) not like "Q%") then 'not selected'
else 'selection' end as selectionresult
from TEMP;

THIS IS THE OUTPUT I AM GETTING:

consumernumber selectionresult
HD not selected
SX not selected
91 not selected
S5 not selected
W not selected
5 not selected
H not selected
SQ not selected
ST not selected
HX not selected
H2 not selected
PGStats
Opal | Level 21
case when first(ConsumerNumber) IN ("4", "H", "M", "N", "Q", "R") then 'Selected' Else 'Not Selected ' end as selectionresult
PG

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1885 views
  • 1 like
  • 3 in conversation