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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.