Conditionally Deleting an Observation

If you do not want the program data vector to write to a data set based on a condition, use the DELETE statement in the DATA step. For example, if the tour to Peru has been discontinued, it is no longer necessary to include the observation for Peru in the data set that is being created. The following example uses the DELETE statement to prevent SAS from writing that observation to the output data set:
data subset;
   set mylib.internationaltours;
   if Country = 'Peru' then delete;
run;

proc print data=subset;
   title 'Omitting a Discontinued Tour';
run;
The following output displays the results:
Display 7.8 Deleting an Observation
The observation for Peru has been deleted from the data set.

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.