BookmarkSubscribeRSS Feed
Ankur32
Obsidian | Level 7

I have 2 data sets, One is containing terminated employees of the organisation and other contains full employee list(working and terminated both) now I want a data set which contain only working employee. I want to use proc sql merge. Please suggest which merge will get the correct data set.

 

 

Thanks in advance !!

10 REPLIES 10
MarkWik
Quartz | Level 8

Where are the samples of the datasets? 

Ankur32
Obsidian | Level 7

I don't have data sets, question was asked in an interview.

Cynthia_sas
SAS Super FREQ
Hi:
You can do either an SQL JOIN or a DATA step MERGE to get what you want. Does the full employee list have any variable such as termination date that you might use for filtering, instead of doing a JOIN or MERGE? Just curious how the "full" employee data might distinguish between employees who need to be paid and employees who do not need to be paid.

Cynthia
Ankur32
Obsidian | Level 7

Hi,

 

thanks for replying. I have only employee id's. which join will give correct answer?

 

novinosrin
Tourmaline | Level 20

all you need is a simple look up with a subquery like:

 

proc sql;
create table want as
select *
from  full_employee 
where employee_id not in (select employee_id from terminated);
quit;
Ankur32
Obsidian | Level 7

Hi,

 

Thanks very much for the reply. Shall we use Join? This question was asked in an interview and they asked me which join will be used to get the data set.

novinosrin
Tourmaline | Level 20

You mentioned "I want a data set which contain only working employee."

 

Challenge your interviewer why you need a join. The need for join arises only when you need to extract a variable/variables from the look up dataset. Your interview question doesn't seem to mandate a pull of any external information. All the best!

 

 

JeffMeyers
Barite | Level 11
This is definitely what I would do in this situation. No need to actually merge datasets.
PGStats
Opal | Level 21

If all you had were IDs you could do:

 

proc sql;
create table want as
select employee_id from full_employee 
except
select employee_id from terminated;
quit;

again, not a join.

 

PG
kiranv_
Rhodochrosite | Level 12

 

proc sql;
create table want as
select a.employee_id
from  full_employee  a
full join 
terminated b
on a.employee_id = b.employee_id
where b.employee_id is missing

with join need to do a full join followed by employee_id is missing for terminated table

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 10 replies
  • 2111 views
  • 4 likes
  • 7 in conversation