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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
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.
Ready to level-up your skills? Choose your own adventure.