Hi Everyone,
I am not sure why my full outer join below keep records appear in both table instead of eliminate them.
Can you please help?
Thanks,
Harry
data Cost_data;
input Product $ cost supplier $;
datalines;
Book 70 ABC
Pencil 3 XYZ
Laptop 1000 AAA
;run;
data Sale_price;
input PRD $ Price Market $ ;
datalines;
Book 1200 MD21201
Pencil 4 VA23344
Phone 1000 MD21102
;
run;
*Put all in 1 code;
proc sql;
create table new
as select * from Cost_data full outer join Sale_price
on Cost_data.product=Sale_price.PRD
;quit;
If you don't want the matches do this.
proc sql; create table new as select * from Cost_data full outer join Sale_price on Cost_data.product=Sale_price.PRD where Cost_data.product ne Sale_price.PRD ;quit;
That's what a full (outer) join does. It keeps all observations, including those where no match is found. If you don't want that, use a left, right or inner join.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.