Desktop productivity for business analysts and programmers

SAS case statement question

Frequent Contributor
Posts: 82

SAS case statement question

In this code:

case when strip(col1 ) then "DIGIT"

when anyalpha( strip(col1)) then "ALPHA"

else "DIGIT"

Under what condition will it evaluate to "DIGIT"? In case col1 = null?

Esteemed Advisor
Posts: 5,624

Re: SAS case statement question

Posted in reply to eagles_dare13

Without a case-operand, the when-expressions must resolve to logical values. Your first expression (strip(col1)) evaluates to a character value. It will be considered FALSE when the result is missing and TRUE otherwise. When it is FALSE then the second condition (anyalpha(strip(col1))) will also be false since strip(col1) is missing and the else-expression will be returned. So, I think that this expression will always evaluate to DIGIT.

What is your intent?


Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation