Hi All 🙂
I have the following problem. I have two datasets have1 and hav1 as below
data have1;
input A $ B C;
datalines;
Peter 10 100
Peter 20 300
Anna 36 900
Kelly 80 700
Kelly 40 400
Kelly 70 800
Max 45 951
Max 12 752
;
data have2;
input A $ B C;
datalines;
Peter 10 100
Anna 36 900
Kelly 80 700
Kelly 70 800
Max 12 752
James 46 943
;
Now I want to extract the observations in have1 that do not exist in have2, which in this case makes my WANT dataset looking like this
data want;
input A $ B C;
datalines;
Peter 20 300
Kelly 40 400
Max 45 951
;
Thank you in advance 🙂
SQL has a nice except join for this:
proc sql; create table WANT as select A,B,C from HAVE 1 except select A,B,C from HAVE2; quit;
SQL has a nice except join for this:
proc sql; create table WANT as select A,B,C from HAVE 1 except select A,B,C from HAVE2; quit;
Very cool, thank you both 🙂
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.