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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1945 views
  • 1 like
  • 3 in conversation