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.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.