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.
Assuming EmpId is Unique :
data want;
merge staff.staffmaster(in=a) staff.staffchanges(in=b);
by empid;
if a and not b;
run;
Assuming EmpId is Unique :
data want;
merge staff.staffmaster(in=a) staff.staffchanges(in=b);
by empid;
if a and not b;
run;
Simply:
proc sql;
create table StaffCurrent as
select * from StaffMaster
where empId not in (select empId from StaffChanges);
quit;
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;
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!
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.