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:
-
Delete the observations that do not meet a condition, keeping only the ones that you want.
-
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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.