Hello. I am trying to merge two datasets. What I would like to do is full join per subject ID even though date_time from dataset 1 doesn't exisit in dataset 2;
First dataset:
SubjectID | date_time | value1 |
123 | 1/1/2010 9:53 | 52.1 |
123 | 1/2/2010 10:31 | 21.2 |
123 | 1/3/2010 9:33 | 32.3 |
456 | 2/1/2010 9:53 | 42.2 |
456 | 2/2/2010 10:31 | 123.4 |
456 | 2/3/2010 9:33 | 47.2 |
456 | 2/4/2010 14:23 | 44.4 |
second dataset:
SubjectID | date_time | value1 | value2 |
123 | 1/1/2010 9:53 | 52.1 | 10.2 |
123 | 1/2/2010 10:31 | 21.2 | 42.1 |
456 | 2/1/2010 9:53 | 42.2 | 44.8 |
456 | 2/4/2010 14:23 | 44.4 | 32.2 |
want:
SubjectID | date_time | value1 | value2 |
123 | 1/1/2010 9:53 | 52.1 | 10.2 |
123 | 1/2/2010 10:31 | 21.2 | 42.1 |
123 | 1/3/2010 9:33 | 32.3 | |
456 | 2/1/2010 9:53 | 42.2 | 44.8 |
456 | 2/2/2010 10:31 | 123.4 | |
456 | 2/3/2010 9:33 | 47.2 | |
456 | 2/4/2010 14:23 | 44.4 | 32.2 |
Here's my code so far:
proc sql;
select t1.subjectid, t1.date_time, t1.value1, t2.value2
from dataset1 t1
left outer join dataset2 t2
where t2.value2 is null
any help would be greatly appreciated
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: