Previous PageNext Page

Use of the Drop or Keep statements
Drop and Keep statements are used to decide which variables in the PDV are written to disk
If it is easier (less typing) to specify which variables you want included in the output data set, use the KEEP statement.

     KEEP Gender Subj Year;

If it is easier to specify which variables you do not want included in the output data set, use the DROP statement.

     DROP Weight Height;

Do not use both DROP and KEEP in the same data step. It is possible, but unlikely, that you will do it correctly.
If you can't decide, use KEEP. It's clearer to see what variables you'll get.

The dropped variables are available during data step execution, even if they are used in statements coming after the Drop or Keep statement.

DROP statement (data step only)
DROP variable-names;

KEEP statement (data step only)
KEEP variable-names;

For more information, see SL:R, Chapter 9 SAS Language statements, DROP and KEEP.

Previous PageTable Of ContentsNext Page