Hallo @sieghild en hartelijk welkom op het forum!
[Switching to English now, sorry! :-)] Normally you shouldn't get this error message with your code as posted because the "result of WHEN clause 2" -- 'minstens 1 maand' -- is a character value as is the "preceding result" -- 'onbepaalde duur'. You would get the error message if you replaced one of the two character strings with a numeric value, e.g., 1.
Here is an example where an exact copy of your code works as expected:
data have;
input id end_date :$8. total_days;
cards;
1 20211231 50000
2 20210713 40000
3 20211011 20000
;
proc sql;
select
case
when p.end_date = '20211231' then 'onbepaalde duur'
when p.total_days/1000 > 30 then 'minstens 1 maand'
else ''
end as ziektetermijn,
id
from have p;
quit;
@sieghild wrote:
p.end_date is een char van 6
p.total_days is ook een char van 6
Are you saying that these are character variables of length 6? That would be a problem because p.end_date could never be equal to an 8-character string such as '20211231' and attempting to divide p.total_days by 1000 would cause an ERROR: Expression using division (/) requires numeric types.
To avoid all these type conflicts, you just need to know the types (and possible values) of your variables and handle them accordingly when coding comparisons, calculations or value assignments.