BookmarkSubscribeRSS Feed
hhchenfx
Barite | Level 11

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.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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