BookmarkSubscribeRSS Feed
hhchenfx
Rhodochrosite | Level 12

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;

 

 

2 REPLIES 2
CurtisMackWSIPP
Lapis Lazuli | Level 10

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;
Kurt_Bremser
Super User

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.

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 938 views
  • 0 likes
  • 3 in conversation