Suppose you have updated data and want to change some values in the Class
data set. For instance, suppose the student named Henry recently had a birthday. You can do the following:
use the EDIT statement to open the Class
data set for input and output
read the data
change the appropriate data value
replace the changed data in the data set
The following statements open the Class
data set and use the FIND statement to find the observation number that corresponds to Henry. The observation number is stored in the matrix Obs
, as shown in Figure 7.15.
proc iml; edit Class; find all where(name={'Henry'}) into Obs; list point Obs;
Figure 7.15: Selected Observation
OBS Name Sex Age Height Weight ------ -------- --- --------- --------- --------- 5 Henry M 14.0000 63.5000 102.5000 |
You can read in the Age
variable, increment its value, and use the REPLACE statement to overwrite the value in the Class
data set, as follows:
read point Obs var {Age}; Age = Age + 1; replace point Obs var {Age}; list point Obs; close Class;
Figure 7.16: New Value
OBS Name Sex Age Height Weight ------ -------- --- --------- --------- --------- 5 Henry M 15.0000 63.5000 102.5000 |
Figure 7.16 shows that the value for Henry’s age has been updated.