BookmarkSubscribeRSS Feed
codyV
Fluorite | Level 6

Hi,

 

i am  using  the  below code to  get a number against the condition. But i only find  the number  getting updated to status = 'new prospect' and not to the status  = 'ACCEPTED-MINE/CHANNEL'.  

I am unsure  what could go wrong with the code. Appreciate your help and suggestions.

 

proc sql;

create table a11 as

select *,

case when ((m_flag = 1) and (s_flag = 0) and (x_flag = 0)) and

((status = 'NEW PROSPECT') and (outcome = 'COMPETITIVE ACCOUNT') or

(status = 'NEW PROSPECT')  and (outcome = 'CONTACTED') or

(status = 'NEW PROSPECT')  and (outcome = 'IMMEDIATE TIMEFRAME') or

(status = 'NEW PROSPECT')  and (outcome = 'QUALIFIED LEAD')  or

(status = 'NEW PROSPECT')  and (outcome = '') or

(status = 'ACCEPTED-MINE/CHANNEL') and (outcome = 'COMPETITIVE ACCOUNT') or

(status = 'ACCEPTED-MINE/CHANNEL') and (outcome = 'CONTACTED') or

(status = 'ACCEPTED-MINE/CHANNEL') and (outcome = 'IMMEDIATE TIMEFRAME') or

(status = 'ACCEPTED-MINE/CHANNEL') and (outcome = 'QUALIFIED LEAD')  or

(status = 'ACCEPTED-MINE/CHANNEL') and (outcome = ''))

then 100  else  0 end as Lscore

from  have;

quit;

3 REPLIES 3
Tom
Super User Tom
Super User

 But i only find  the number  getting updated to status = 'new prospect' and not to the status  = 'ACCEPTED-MINE/CHANNEL'.  

Are you sure you posted the right combination of question and code?

The code you posted is only testing the values of STATUS, not updating them.

 

PGStats
Opal | Level 21

Check the spelling of ACCEPTED-MINE/CHANNEL carefully, especially the hyphen. There are many characters that print like a dash or hyphen.

PG
Tom
Super User Tom
Super User

You have illogical AND/OR combination.  I think you need to add more ().

You have this pattern:

(  (status = 'NEW PROSPECT') and (outcome = 'COMPETITIVE ACCOUNT') 
or (status = 'NEW PROSPECT') and (outcome = 'CONTACTED') 
or  ...
)

and you probably meant this pattern instead.

(  ((status = 'NEW PROSPECT') and (outcome = 'COMPETITIVE ACCOUNT'))
or ((status = 'NEW PROSPECT') and (outcome = 'CONTACTED'))
or  ...
)

You might want to split the different conditions into different WHEN clauses.

Perhaps something like:

case when (m_flag ne 1) then 0
     when (s_flag ne 0) then 0
     when (x_flag ne 0) then 0
...

 

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!
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
  • 376 views
  • 0 likes
  • 3 in conversation