Use the DELETE statement to mark an observation for subsequent deletion. The general form of the DELETE statement is as follows:
DELETE <range> <WHERE(expression)> ;
where
specifies a range of observations. For details, see the section Process a Range of Observations.
is an expression that is evaluated as being true or false. For details about the WHERE clause, see the section Process Data by Using the WHERE Clause.
The DELETE statement marks observations for deletion. To actually delete the marked observations and renumber the remaining observations, use the PURGE statement .
Suppose the student named John has moved and you want to delete the corresponding observation from the Class
data set, which was created in the section Edit a SAS Data Set. The following statements find the observation for John and mark it for deletion:
edit Class; find all where(name={'John'}) into Obs; delete point Obs;
To update the data set and renumber the observations, use the PURGE statement. Be aware that the PURGE statement deletes any indexes associated with a data set.
purge; show contents;
Figure 7.17: Updated Data Set
The data set now has 18 observations, whereas it used to have 19.