DELETE <range> <WHERE(expression)> ;
The DELETE statement marks observations (also called records) in the current output data set for deletion. To actually delete the records and renumber the remaining observations, use the PURGE statement .
The arguments to the DELETE statement are as follows:
specifies a range of observations. You can specify a range of observations by using the ALL, CURRENT, NEXT, AFTER, and POINT keywords, as described in the section Process a Range of Observations.
specifies a criterion by which certain observations are selected. The optional WHERE clause conditionally selects observations that are contained within the range specification. For details about the WHERE clause, see the section Process Data by Using the WHERE Clause.
The following statements show examples of using the DELETE statement:
proc iml; /* create sample data set */ sex = { M, M, M, F, F, F}; age = {34, 28, 38, 32, 24, 18}; create MyData var {"Sex" "Age"}; append; close MyData; /* delete observations in data set */ edit MyData; delete; /* marks the current obs */ delete point 3; /* marks obs 3 */ delete all where(age<21); /* marks obs where age<21 */ purge; /* deletes all marked obs */ close MyData; proc print data=MyData; run;
Notice that observations marked for deletion by using the DELETE statement are not physically removed from the data set until a PURGE statement is executed.