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

I have attached the two datasets I'm working with. I need to merge the staffmaster and staffchanges datasets but exclude the people found in the staff changes from the staffmaster dataset. How could I go about doing that? I've attached the two datasets.

1 ACCEPTED SOLUTION

Accepted Solutions
r_behata
Barite | Level 11

Assuming EmpId is Unique :

 

data want;
	merge staff.staffmaster(in=a) staff.staffchanges(in=b);
	by empid;

	if a and not b;
run;

View solution in original post

3 REPLIES 3
r_behata
Barite | Level 11

Assuming EmpId is Unique :

 

data want;
	merge staff.staffmaster(in=a) staff.staffchanges(in=b);
	by empid;

	if a and not b;
run;
PGStats
Opal | Level 21

Simply:

 

proc sql;
create table StaffCurrent as
select * from StaffMaster
where empId not in (select empId from StaffChanges);
quit;
PG
PeterClemmensen
Tourmaline | Level 20
data want;
   if 0 then set staff.staffchanges;
   if _N_ = 1 then do;
      declare hash h(staff.staffchanges);
      h.defineKey('empid');
      h.defineData(all:"Y");
      h.defineDone();
   end;

   set staff.staffmaster;

   rc=h.check();
   if rc ne 0;
run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—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
  • 3 replies
  • 2225 views
  • 0 likes
  • 4 in conversation