The problem with your code is the statement when adjud_dt ='' then paid_dt.
Date being a numeric one must use adjud_dt = .
This is because missing numeric values are represented by a dot or period and not as used in the code. The two single quotes as used in the code posted indicate a missing character value. That is what the error message is indicating. I am giving the sample code below which works correctly.
data old;
informat adjud_dt paid_dt date9.;
format adjud_dt paid_dt date9.;
input adjud_dt paid_dt;
datalines;
23DEC2021 22DEC2021
20DEC2021 21DEC2021
. 19DEC2021
;
run;
proc sql;
create table new as
select *,
case
when adjud_dt=. then paid_dt
else adjud_dt
end as new_adjud_dt format date9.
from old;
quit;
one can also use missing function as shown by @PaigeMiller , in that case the sql statement would be as follows
proc sql;
create table new as
select *,
case
when missing(adjud_dt) then paid_dt
else adjud_dt
end as new_adjud_dt format date9.
from old;
quit;
Either way the result is same.
... View more