ID | a | b | c | d |
1 | 1 | 1 | 1 | |
1 | 2 | 2 | 2 | |
1 | b | 3 | 3 | 3 |
1 | 4 | 4 | 4 |
ID | a |
1 | c |
The result should look like:
ID | a | b | c | d |
1 | c | 1 | 1 | 1 |
1 | c | 2 | 2 | 2 |
1 | b | 3 | 3 | 3 |
1 | c | 4 | 4 | 4 |
Thanks!!!
proc sql;
create table want as
select
t1.id,
coalesce(t1.a,t2.a) as a,
t1.b,
t1.c,
t1.d
from have t1 left join upd t2
on t1.id = t2.id
;
quit;
Does your second data set always have just one obs?
data one;
infile datalines dlm = ',' missover dsd;
input ID a $ b c d;
datalines;
1, ,1,1,1
1, ,2,2,2
1,b,3,3,3
1, ,4,4,4
;
data two;
input ID a $;
datalines;
1 c
;
data want;
set one;
z = 1;
if a = "" then set two point = z;
run;
proc sql;
create table want as
select
t1.id,
coalesce(t1.a,t2.a) as a,
t1.b,
t1.c,
t1.d
from have t1 left join upd t2
on t1.id = t2.id
;
quit;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.