Hello I have the following question.
I have a data set called 'tbl1' which contain fields: x,y1,y2.
Sometimes there another data set called "recovery_tbl' which contain fields: x,w,y1,y2
If in specific field all values are missing(null values in all columns) then If a recovery data set exists it will gather the values from there.
Data tbl1;
input ID y1 y2;
cards;
1 10 .
2 20 .
3 30 .
4 40 .
5 50 .
;
Run;
Data recovery_tbl;
input ID w y1 y2;
cards;
1 5 10 100
2 6 20 200
3 7 30 300
4 8 40 400
5 9 50 500
;
Run;
PROC SQL;
create table tbl1_new as
select a.ID,a.Y1,coalesce(a.Y2,b.Y2) as Y2
from tbl1 as a
left join recovery_tbl as b
on a.ID=b.ID
;
QUIT;
Can anyone how to perform this conditional merge. The merge need to be done only if 2 conditions happens: 1-There is a field that all values are null (missing values) 2- A recover table exists