DROP= Data Set Option

For an input data set, excludes the specified variables from processing; for an output data set, excludes the specified variables from being written to the data set.

Valid in: DATA step and PROC steps
Category: Variable Control

Syntax

Syntax Description

variable(s)

lists one or more variable names. You can list the variables in any form that SAS allows.

Details

If the option is associated with an input data set, the variables are not available for processing. If the DROP= data set option is associated with an output data set, SAS does not write the variables to the output data set, but they are available for processing.

Comparisons

The DROP= data set option differs from the DROP statement in these ways:
  • In DATA steps, the DROP= data set option can apply to input and output data sets. The DROP statement applies only to output data sets.
  • In DATA steps, when you create multiple output data sets, use the DROP= data set option to write different variables to different data sets. The DROP statement applies to all output data sets.
  • In PROC steps, you can use only the DROP= data set option, not the DROP statement.

Examples

Example 1: Excluding Variables from Input

In this example, the variables SALARY and GENDER are not included in processing, and they are not written to either output data set:
data plan1 plan2;
   set payroll(drop=salary gender);
   if hired<'01jan98'd then output plan1;
   else output plan2;
run;
You cannot use SALARY or GENDER in any logic in the DATA step because DROP= prevents the SET statement from reading SALARY and GENDER from PAYROLL.

Example 2: Processing Variables without Writing Them to a Data Set

In this example, SALARY and GENDER are not written to PLAN2, but they are written to PLAN1:
data plan1 plan2(drop=salary gender);
   set payroll; 
   if hired<'01jan98'd then output plan1;
   else output plan2;
run;

See Also

Data Set Options:
Statements:
DROP Statement in SAS Statements: Reference