Piggybacking on @Ksharp's code here an option which modifies the master data set in place.
data master;
set sashelp.class;
run;
data trans;
length name $ 8 sex $ 1;
/* updates */
name='Robert';
sex='N';
output;
name='Thomas';
sex='A';
output;
/* inserts */
name='Ksharp';
sex='M';
output;
run;
data master(drop=_:);
modify master end=last;
if _n_=1 then
do;
dcl hash h1(dataset:'trans');
dcl hiter hh1('h1');
_rc=h1.defineKey('Name');
_rc=h1.defineData(all:'y');
_rc=h1.defineDone();
end;
/* updates */
if h1.find()=0 then
do;
replace;
_rc=h1.remove();
end;
/* inserts */
if last then
do;
_rc = hh1.first();
do while (_rc = 0);
output;
_rc = hh1.next();
end;
end;
run;
Please Note that for the Insert case all values for variables which only exist in the Master dataset but not in the Transaction dataset get retained (which is of course wrong).
If you don't have all variables in your transaction dataset then you need to use a "call missing()" for the Insert case for all variables which only exist in the master dataset.
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.