Published on :
DATA Step Programming CREATION_INTERNE

DROP Statement

This code is also available in: Deutsch Español Français
Awaiting validation
The DROP statement applies to all SAS© data sets created during the same DATA step and can appear anywhere in that step. Variables specified in the DROP statement are available for processing within the DATA step but are not written to the output data sets. If no DROP or KEEP statement is present, all data sets created in the DATA step contain all variables. It is important not to use both DROP and KEEP statements simultaneously in the same DATA step. If the same variable is listed in both statements, DROP takes precedence over KEEP, regardless of the order of the statements, and the variable is excluded.
Data Analysis

Type : CREATION_INTERNE


The provided examples illustrate the use of the DROP statement with internal variables or implicit file specifications.

1 Code Block
DATA Step
Explanation :
This example shows how to explicitly list the variables 'time', 'shift', and 'batchnum' to exclude them from output SAS data sets. These variables will be used during the DATA step but will not appear in the final data set.
Copied!
1drop time shift batchnum;
2 Code Block
DATA Step
Explanation :
This example illustrates dropping a range of variables ('grade1' to 'grade20') using range notation in the DROP statement. All variables within this range will be excluded from the output SAS data set.
Copied!
1drop grade1-grade20;
3 Code Block
DATA Step Data
Explanation :
In this example, the variables 'purchase' and 'repair' are used for processing (calculating 'totcost'), but they are dropped from the output data set 'inventry'. The final data set 'inventry' will contain the variables 'unit', 'part', and 'totcost', but not 'purchase' or 'repair'. The 'infile file-specification' statement is a placeholder for the input file specification.
Copied!
1DATA inventry;
2 drop purchase repair;
3 INFILE file-specification;
4 INPUT unit part purchase repair;
5 totcost=sum(purchase,repair);
6RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Copyright © SAS Institute Inc. All Rights Reserved