Previous Page | Next Page

Modifying SAS Data Sets

Handling Missing Values

By default, if the transaction data set contains missing values for a variable that is common to both the master and the transaction data sets, then the MODIFY statement does not replace values in the master data set with missing values.

If you want to replace values in the master data set with missing values, then you use the UPDATEMODE= option on the MODIFY statement. UPDATEMODE specifies whether missing values in a transaction data set will replace existing values in a master data set.

The syntax for using the UPDATEMODE= option with the MODIFY statement is

MODIFY master-SAS-data-set transaction-SAS-data-set <UPDATEMODE=MISSINGCHECK | NOMISSINGCHECK>;
BY by-variable;

MISSINGCHECK prevents missing values in a transaction data set from replacing values in a master data set. This is the default. NOMISSINGCHECK enables missing values in a transaction data set to replace values in a master data set by preventing the check for missing data from being performed.

The following example creates the master data set Event_List, which contains the schedule and codes for athletic events. The example then updates Event_List with the transaction data set Event_Change, which contains new information about the schedule. Because the MODIFY statement uses the NOMISSINGCHECK value of the UPDATEMODE= option, values in the master data set are replaced by missing values from the transaction data set.

The following program creates the EVENT_LIST master data set:

data Event_List;
   input Event $ 1-10 Weekday $ 12-20 TimeofDay $ 22-30 Fee Code; 
   datalines;
Basketball Monday    evening   10 58
Soccer     Tuesday   morning   5  33
Yoga       Wednesday afternoon 15 92
Swimming   Wednesday morning   10 63
;

The following program creates the EVENT_CHANGE transaction data set:

data Event_Change;
   input Event $ 1-10 Weekday $ 12-20 Fee Code;
   datalines;
Basketball Wednesday 10 .
Yoga       Monday    . 63
Swimming             .  .
;

The following program modifies and prints the master data set:

options pagesize=60 linesize=80 pageno=1 nodate;

data Event_List;
    modify Event_List Event_Change updatemode=nomissingcheck; 
    by Event;
 run;

proc print data=Event_List;
   title 'Schedule of Athletic Events';
run;

The following output shows the results:

The EVENT_LIST Master Data Set: Missing Values

                          Schedule of Athletic Events                          1

           Obs    Event         Weekday      TimeofDay    Fee    Code

            1     Basketball    Wednesday    evening       10      . 
            2     Soccer        Tuesday      morning        5     33 
            3     Yoga          Monday       afternoon      .     63 
            4     Swimming                   morning        .      . 

Previous Page | Next Page | Top of Page