Updating a data set
The
update
statement creates a new
data set by coping values from a
master data set and applying changes from a
transaction data set.
In the following example, a master data set is created (tq84_master
) which contains a typo and a »missing« observation. Both issues are fixed by applying the tq84_transaction
data set:
data tq84_master;
length txt $10.;
num = 1; txt = 'one' ; output;
num = 2; txt = 'two' ; output;
num = 3; txt = 'trhee'; output; /* Note the typo */
num = 4; txt = 'four' ; output;
num = 6; txt = 'six' ; output; /* Note the missing 5 */
run;
data tq84_transaction;
length txt $10.;
num = 3; txt = 'three'; output; /* Fix the typo */
num = 5; txt = 'five' ; output; /* Add the missing 5 */
run;
data tq84_updated;
update
tq84_master
tq84_transaction;
by num;
run;
proc print data=tq84_updated noobs; run;
/*
txt num
one 1
two 2
three 3
four 4
five 5
six 6
*/