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
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!
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.