| 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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.