Understanding DATA Step Processing |
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:
options pagesize=60 linesize=80 pageno=1 nodate; 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:
Omitting a Discontinued Tour 1 Air Land Obs Country Nights Cost Cost Vendor 1 France 8 793 575 Major 2 Spain 10 805 510 Hispania 3 India 10 . 489 Royal
The observation for Peru has been deleted from the data set.
Copyright © 2012 by SAS Institute Inc., Cary, NC, USA. All rights reserved.