Hello
I have two datasets. Lets call them dataset1 and dataset2.
I want to create a third dataset who contains records not in both dataset based on my keyvar.
Thank you!
Kind regards Frank
See this simplified example:
data one;
input CPR $;
datalines;
123
456
789
;
data two;
input CPR $;
datalines;
000
123
789
;
data check;
merge
one (in=one)
two (in=two)
;
by CPR;
if not (one and two);
run;
Both datasets need to be sorted by CPR.
How can you create a third dataset who contains records not in "both" dataset based on my keyvar.
Are you looking for EXCEPT rule?
Let me try to explain.
I have two different datasets with different variables. Both of them contain a Danish 'CPR' number which in this situation is my ID var.
A patient can be in dataset1 and not in dataset2 and opposite. I want to find those patients whos not in both datasets based on my ID var.
In STATA I can use 'merge' and choose those patients where there is no match.
Can I do something similar in sas?
See this simplified example:
data one;
input CPR $;
datalines;
123
456
789
;
data two;
input CPR $;
datalines;
000
123
789
;
data check;
merge
one (in=one)
two (in=two)
;
by CPR;
if not (one and two);
run;
Both datasets need to be sorted by CPR.
Nearly 200 sessions are now available on demand in the Innovate Hub.
Watch Now →SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.