DROP= Data Set Option

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

Valid in: DATA and PROC steps
Category: Variable Control
Supports: All

Syntax

Syntax Description

column(s)

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

Details

If the option is associated with an input data set, the columns are not available for processing. If the DROP= data set option is associated with an output data set, SAS does not write the columns 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 both 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 columns 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.
  • The KEEP= data set option specifies a list of columns to be included in processing or to be written to the output data set.

Examples

Example 1: Excluding Columns from Input

In this example, the columns Salary and Gender are not included in processing and they are not written to either output data set:
data payroll;
   input idnum $3. +3 gender $1. +4 jobcode $3. +9 salary 5.
         +2 birth date7. +2 hired date7.;
   informat birth date7. hired date7.;
   format birth date7. hired date7.;
   datalines;
919   M    TA2         34376  12SEP60  04JUN87
653   F    ME2         35108  15OCT64  09AUG90
400   M    ME1         29769  05NOV67  16OCT90
350   F    FA3         32886  31AUG65  29JUL90
401   M    TA3         38822  13DEC50  17NOV85
499   M    ME3         43025  26APR54  07JUN80
101   M    SCP         18723  06JUN62  01OCT90
333   M    PT2         88606  30MAR61  10FEB81
402   M    TA2         32615  17JAN63  02DEC90
479   F    TA3         38785  22DEC68  05OCT89
403   M    ME1         28072  28JAN69  21DEC91
739   M    PT1         66517  25DEC64  27JAN91
658   M    SCP         17943  08APR67  29FEB92
428   F    PT1         68767  04APR60  16NOV91
782   M    ME2         35345  04DEC70  22FEB92
244   M    ME2         36925  31AUG63  17JAN88
383   M    BCK         25823  25JAN68  20OCT92
574   M    FA2         28572  27APR60  20DEC92
789   M    SCP         18326  25JAN57  11APR78
404   M    PT2         91376  24FEB53  01JAN80
437   F    FA3         33104  20SEP60  31AUG84
639   F    TA3         40260  26JUN57  28JAN84
269   M    NA1         41690  03MAY72  28NOV92
065   M    ME2         35090  26JAN44  07JAN87
876   M    TA3         39675  20MAY58  27APR85
037   F    TA1         28558  10APR64  13SEP92
129   F    ME2         34929  08DEC61  17AUG91
988   M    FA3         32217  30NOV59  18SEP84
405   M    SCP         18056  05MAR66  26JAN92
430   F    TA2         32925  28FEB62  27APR87
983   F    FA3         33419  28FEB62  27APR87
134   F    TA2         33462  05MAR69  21DEC88
118   M    PT3        111379  16JAN44  18DEC80
438   F    TA3         39223  15MAR65  18NOV87
125   F    FA2         28888  08NOV68  11DEC87
475   F    FA2         27787  15DEC61  13JUL90
117   M    TA3         39771  05JUN63  13AUG92
935   F    NA2         51081  28MAR54  16OCT81
124   F    FA1         23177  10JUL58  01OCT90
422   F    FA1         22454  04JUN64  06APR91
616   F    TA2         34137  01MAR70  04JUN93
406   M    ME2         35185  08MAR61  17FEB87
120   M    ME1         28619  11SEP72  07OCT93
094   M    FA1         22268  02APR70  17APR91
389   M    BCK         25028  15JUL59  18AUG90
905   M    PT1         65111  16APR72  29MAY92
407   M    PT1         68096  23MAR69  18MAR90
114   F    TA2         32928  18SEP69  27JUN87
410   M    PT2         84685  03MAY67  07NOV86
439   F    PT1         70736  06MAR64  10SEP90
409   M    ME3         41551  19APR50  22OCT81
408   M    TA2         34138  29MAR60  14OCT87
121   M    ME1         29112  26SEP71  07DEC91
991   F    TA1         27645  07MAY72  12DEC92
102   M    TA2         34542  01OCT59  15APR91
356   M    ME2         36869  26SEP57  22FEB83
545   M    PT1         66130  12AUG59  29MAY90
292   F    ME2         36691  28OCT64  02JUL89
440   F    ME2         35757  27SEP62  09APR91
368   M    FA2         27808  11JUN61  03NOV84
369   M    TA2         33705  28DEC61  13MAR87
411   M    FA2         27265  27MAY61  01DEC89
113   F    FA1         22367  15JAN68  17OCT91
704   M    BCK         25465  30AUG66  28JUN87
900   M    ME2         35105  25MAY62  27OCT87
126   F    TA3         40899  28MAY63  21NOV80
677   M    BCK         26007  05NOV63  27MAR89
441   F    FA2         27158  19NOV69  23MAR91
421   M    TA2         33155  08JAN59  28FEB90
119   M    TA1         26924  20JUN62  06SEP88
834   M    BCK         26896  08FEB72  02JUL92
777   M    PT3        109630  23SEP51  21JUN81
663   M    BCK         26452  11JAN67  11AUG91
106   M    PT2         89632  06NOV57  16AUG84
103   F    FA1         23738  16FEB68  23JUL92
477   M    FA2         28566  21MAR64  07MAR88
476   F    TA2         34803  30MAY66  17MAR87
379   M    ME3         42264  08AUG61  10JUN84
104   M    SCP         17946  25APR63  10JUN91
009   M    TA1         28880  02MAR59  26MAR92
412   M    ME1         27799  18JUN56  05DEC91
115   F    FA3         32699  22AUG60  29FEB80
128   F    TA2         32777  23MAY65  20OCT90
442   F    PT2         84536  05SEP66  12APR88
417   M    NA2         52270  27JUN64  07MAR89
478   M    PT2         84203  09AUG59  24OCT90
673   M    BCK         25477  27FEB70  15JUL91
839   F    NA1         43433  29NOV70  03JUL93
;
data myfiles.plan1 myfiles.plan2;
   set myfiles.payroll (drop=salary gender);
   if hired <'01jan98'd then output myfiles.plan1;
   else output myfiles.plan2;
run;
proc print data=myfiles.plan1(obs=2);
   title 'plan1';
proc print data=myfiles.plan2(obs=2);
   title 'plan2';
run;
You cannot use Salary or Gender in any logic in the DATA step because DROP= prevents the SET statement from reading them from Payroll.

Example 2: Processing Columns 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 myfiles.plan1 myfiles.plan2 (drop=salary gender);
   set myfiles.payroll;
   if hired <'01jan98'd then output myfiles.plan1;
   else output myfiles.plan2;
run;