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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.