In this example, the data
set MASTER2 is a master data set. It contains a missing value for
the variable Plant2 in the first observation, and not all of the values
of the BY variable Common are included. The transaction data set NONPLANT
contains a new variable Mineral, a new value of the BY variable Common,
and missing values for several observations. The following shows
the MASTER2 and the NONPLANT input data sets:
MASTER2 NONPLANT
OBS Common Animal2 Plant2 OBS Common Plant2 Mineral
1 a Ant 1 a Apricot Amethyst
2 c Cat Coconut 2 b Barley Beryl
3 d Dog Dewberry 3 c Cactus
4 e Eagle Eggplant 4 e
5 f Frog Fig 5 f Fennel
6 g Grape Garnet
The following program
updates the data set MASTER2 and prints the results:
data update2_file;
update master2 nonplant;
by Common;
run;
proc print data=update2_file;
title 'Data Set Update2_File';
run;
Results of Updating with New Variables, Nonmatched Observations,
and Missing Values
As shown, all observations
now include values for the variable Mineral. The value of Mineral
is set to missing for some observations. Observations 2 and 6 in the
transaction data set did not have corresponding observations in MASTER2,
and they have become new observations. Observation 3 from the master
data set was written to the new data set without change, and the value
for Plant2 in observation 4 was not changed to missing. Three observations
in the new data set have updated values for the variable Plant2.
The following program
uses the UPDATEMODE statement option in the UPDATE statement, and
prints the results:
data update2_file;
update master2 nonplant updatemode=nomissingcheck;
by Common;
run;
proc print data=update2_file;
title 'Data Set Update2_File - UPDATEMODE Option';
run;
Results of Updating with the UPDATEMODE Option
The value of Plant2
in observation 5 is set to missing because the UPDATEMODE=NOMISSINGCHECK
option is in effect.
For detailed examples
for updating data sets, see
Combining and Modifying SAS
Data Sets: Examples.