BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
varmalh
Fluorite | Level 6

Hello all,

can someone please help me to get the same output from SQL as i am getting from base SAS from the below code....????

 

data a;
input emp$ sal;
cards;
emp1 1000000
emp2 2000000
emp3 3000000
;run;

data b;
input emp$ sal;
cards;
emp1 1000000
emp3 7000000
emp4 4000000
;run;

data c;
update a b;
by emp;
run;

data c;
merge a(in=x) b(in=y);
by emp;
run;

 output should be like below:

---------------------

emp1 1000000
emp2 2000000
emp3 7000000
emp4 4000000

---------------------

 

 

Thanks and Regards

varmalh

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21
proc sql;
select 
	coalesce(b.emp, a.emp) as emp,
	coalesce(b.sal, a.sal) as sal
from a full outer join b on a.emp=b.emp;
quit;

@varmalh wrote:

Hello all,

can someone please help me to get the same output from SQL as i am getting from base SAS from the below code....????

 

data a;
input emp$ sal;
cards;
emp1 1000000
emp2 2000000
emp3 3000000
;run;

data b;
input emp$ sal;
cards;
emp1 1000000
emp3 7000000
emp4 4000000
;run;

data c;
update a b;
by emp;
run;

data c;
merge a(in=x) b(in=y);
by emp;
run;

 output should be like below:

---------------------

emp1 1000000
emp2 2000000
emp3 7000000
emp4 4000000

---------------------

 

 

Thanks and Regards

varmalh


 

PG

View solution in original post

1 REPLY 1
PGStats
Opal | Level 21
proc sql;
select 
	coalesce(b.emp, a.emp) as emp,
	coalesce(b.sal, a.sal) as sal
from a full outer join b on a.emp=b.emp;
quit;

@varmalh wrote:

Hello all,

can someone please help me to get the same output from SQL as i am getting from base SAS from the below code....????

 

data a;
input emp$ sal;
cards;
emp1 1000000
emp2 2000000
emp3 3000000
;run;

data b;
input emp$ sal;
cards;
emp1 1000000
emp3 7000000
emp4 4000000
;run;

data c;
update a b;
by emp;
run;

data c;
merge a(in=x) b(in=y);
by emp;
run;

 output should be like below:

---------------------

emp1 1000000
emp2 2000000
emp3 7000000
emp4 4000000

---------------------

 

 

Thanks and Regards

varmalh


 

PG

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
  • 1 reply
  • 372 views
  • 0 likes
  • 2 in conversation