DROP Statement


Excludes variables from output SAS data sets

Valid: in a DATA step

Category: Information

Type: Declarative

Syntax

DROP variable-list ;

Arguments

variable-list

  • specifies the names of the variables to omit from the output data set.

  • Tip: You can list the variables in any form that SAS allows.

Details

The DROP statement applies to all the SAS data sets that are created within the same DATA step and can appear anywhere in the step. The variables in the DROP statement are available for processing in the DATA step. If no DROP or KEEP statement appears, all data sets that are created in the DATA step contain all variables. Do not use both DROP and KEEP statements within the same DATA step.

Comparisons

  • The DROP statement differs from the DROP= data set option in the following ways:

    • You cannot use the DROP statement in SAS procedure steps.

    • The DROP statement applies to all output data sets that are named in the DATA statement. To exclude variables from some data sets but not from others, use the DROP= data set option in the DATA statement.

  • The KEEP statement is a parallel statement that specifies a list of variables to write to output data sets. Use the KEEP statement instead of the DROP statement if the number of variables to include is significantly smaller than the number to omit.

  • Do not confuse the DROP statement with the DELETE statement. The DROP statement excludes variables from output data sets; the DELETE statement excludes observations.

Examples

  • These examples show the correct syntax for listing variables with the DROP statement:

    • drop time shift batchnum;

    • drop grade1-grade20;

  • In this example, the variables PURCHASE and REPAIR are used in processing but are not written to the output data set INVENTRY:

     data inventry;     drop purchase repair;     infile  file-specification  ;     input unit part purchase repair;     totcost=sum(purchase,repair);  run; 

See Also

Data Set Option:

  • DROP= Data Set Option on page 17

Statements:

  • DELETE Statement on page 1137

  • KEEP Statement on page 1276




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net