BookmarkSubscribeRSS Feed
jeremyyjm
Calcite | Level 5

/*method1*/

data exe1;

input id $ dep $ salary;

cards;

1003 bd .

;

data exe2;

input id $ dep $ salary;

cards;

1001 ac 2100

1003 bd 2900

;

proc sql;

select exe1.id, exe1.dep,exe2.salary

from exe1 left join exe2

on exe1.id=exe2.id

and exe1.dep=exe2.dep;

quit;

/*method2*/

data e1;

input id $ dep $ age ;

cards;

1001 ac 23

1002 ac 25

1001 bk 19

1003 bd 22

;

data e2;

input id $ dep $ salary;

cards;

1001 ac 2300

1002 ac 2500

1001 bk 1900

;

data e3;

input id $ dep $ salary;

cards;

1001 ac 2100

l003 bd 2900

;

proc sql;

create table a as

select e1.id,e1.dep,salary

from e1 left join e2

on e1.id=e2.id

and e1.dep=e2.dep

where salary is not null;

quit;

proc sql;

create table b as

select e1.id,e1.dep,salary

from e1 left join e2

on e1.id=e2.id

and e1.dep=e2.dep

where salary is null;

quit;

proc sql;

select b.id,b.dep,e3.salary

from b left join e3

on b.id=e3.id

and b.dep=e3.dep;

quit;

 

Can someone help me, why there are two different results from method 1 and method 2?

2 REPLIES 2
SuryaKiran
Meteorite | Level 14

Check your e3 dataset. It's not 1003 you have there 'l' Letter 'L' instead of one '1'.

Capture.PNG

Thanks,
Suryakiran
jeremyyjm
Calcite | Level 5

thank you so much Suryakiran

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 724 views
  • 2 likes
  • 2 in conversation