Hello and thank you for taking the time to look at this for me.
I have two dataset that I am working with in SAS 9.2. I need to match by a common id (parent_id) then I need to pull the data from one data set and copy it to the other data set that has the matching parent_id. This data set also has multiple of the same parent_id for some cases, but the child_ids are unique for each and every parent.
Data Have 1
parent_id child_id child_info
1 a unique_1
2 b unique_2
2 c unique_3
2 d unique_4
3 e unique_5
4 f unique_6
4 g unique_7
Data 2 Have
parent_id parent_info Parent_info2
1 aa aaa
2 bb bbb
3 cc ccc
4 dd ddd
Data Want
Parent_id Child_id child_info parent_info parent_info2
1 a unique_1 aa aaa
2 b unique_2 bb bbb
2 c unique_3 bb bbb
2 d unique_4 bb bbb
3 e unique_5 cc ccc
4 f unique_6 dd ddd
4 g unique_7 dd ddd
Guidance on this topic is greatly appreciated.
Thank you,
Jeff S. O,
Basic Left Join
Proc sql;
create table want as
select a.*, b.parent_info, b.parent_info2
from dataset1 as a left join dataset2 as b
on a.parent_id = b.parent_id;
quit;
Join...?
Basic Left Join
Proc sql;
create table want as
select a.*, b.parent_info, b.parent_info2
from dataset1 as a left join dataset2 as b
on a.parent_id = b.parent_id;
quit;
Or go natural:
Proc sql;
create table want as
select *
from dataset1 natural left join dataset2;
quit;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.