Desktop productivity for business analysts and programmers

SAS case statement question

Reply
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?

Respected Advisor
Posts: 4,821

Re: SAS case statement question

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?

PG

PG
Ask a Question
Discussion stats
  • 1 reply
  • 157 views
  • 0 likes
  • 2 in conversation