Updating Observations

Suppose you have updated data and want to change some values in the CLASS data set. For instance, suppose the student named Henry has had a birthday since the data were added to the CLASS data set. You can do the following:

  • make the CLASS data set current for input and output

  • read the data

  • change the appropriate data value

  • replace the changed data in the data set

First, submit an EDIT statement to make the CLASS data set current for input and output. Then use the FIND statement, which finds observation numbers and stores them in a matrix, to find the observation number of the data for Henry and store it in the matrix . Here are the statements:

   > edit class;
   > find all where(name={'HENRY'}) into d;
   > print d;

                                D
                               12

The following statement lists the observation that contains the data for Henry:

   > list point d;

        OBS NAME     SEX            AGE    HEIGHT    WEIGHT
     ------ -------- -------- --------- --------- ---------
         12 HENRY    M          14.0000   63.5000  102.5000

As you see, the observation number is 12. Now read the value for AGE into a matrix and update its value. Finally, replace the value in the CLASS data set and list the observation that contains the data for Henry again. Here are the statements:

   > age=15;
   > replace;

                          1 observations replaced.

   > list point 12;

        OBS NAME     SEX            AGE    HEIGHT    WEIGHT
     ------ -------- -------- --------- --------- ---------
         12 HENRY    M          15.0000   63.5000  102.5000