Selecting Observations for a New SAS Data Set

Deleting Observations Based on a Condition

There are two ways to select specific observations in a SAS data set when you create a new SAS data set:
  1. Delete the observations that do not meet a condition, keeping only the ones that you want.
  2. Accept only the observations that meet a condition.
To delete an observation, first identify it with an IF condition, and then use a DELETE statement in the THEN clause:
IF condition THEN DELETE;
Processing the DELETE statement for an observation causes SAS to return immediately to the beginning of the DATA step for a new observation without writing the current observation to the output DATA set. The DELETE statement does not include the observation ...

Get Step-by-Step Programming with Base SAS 9.4 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.