@new_sas_user_4 wrote:
Hi,
I am writing a when clause saying:
case when put(AB,1.)='1' then XY='0' else XY end as XY
AB is numeric and so to put it in the case statement I converted it to char but it is still saying the error "Result of when clause 2 is not the same data type as the preceding results".
XY is character.
How can I put the case statement here !
The expression XY='0' is a Boolean expression, it evaluates as either true or false which in SAS is a numeric one or zero. So you can't have a numeric in one case (when put(AB,1.)='1' then XY='0') and a character XY in the other case.
Try this:
case when AB=1 then '0' else XY end as XY
--
Paige Miller