Hi!
I'm trying to re-work this Case When statement from SQL for use in SAS 9.4.
SQL / Example: Sum(Case When IsNull(mkt_name,'') not in ('TBC', 'Web') then 1 else 0 end) as Cnt_Received_Branch
Here is what I think it should read:
SAS / Solution: Sum(Case When mkt_name Is Null and NOT In ('TBC','Web') then 1 else 0 end) as Cnt_Received
However it is erroring out. Any suggestions would be much appreciated. I simply need the SAS equivalent for this:
SQL / Example: Sum(Case When IsNull(mkt_name,'') not in ('TBC', 'Web') then 1 else 0 end) as Cnt_Received_Branch
Thank you SAS community,
Andrew
When mkt_name is null, then it also is not in ('TBC','Web')
So your query is not doing something reasonable, and probably needs to be modified.
Nevertheless, the SAS syntax is
Case When mkt_name Is Null and mkt_name NOT In ('TBC','Web')
If this gives you the correct answer, it would certainly be easier to understand:
Sum(Case When mkt_name in ('TBC', 'Web') then 0 else 1 end) as Cnt_Received_Branch
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.