DROP and KEEP Subcommands (ADD FILES command)
DROP
and KEEP
are used to include only a subset of
variables in the resulting file. DROP
specifies a set of variables to exclude and KEEP
specifies a set of variables to retain.
-
DROP
andKEEP
do not affect the input files on disk. -
DROP
andKEEP
must follow allFILE
andRENAME
subcommands. -
DROP
andKEEP
must specify one or more variables. IfRENAME
is used to rename variables, specify the new names onDROP
andKEEP
. -
DROP
andKEEP
take effect immediately. If a variable specified onDROP
orKEEP
does not exist in the input files, was dropped by a previousDROP
subcommand, or was not retained by a previousKEEP
subcommand, the program displays an error message and does not execute theADD FILES
command. -
DROP
cannot be used with variables created by theIN
,FIRST
, orLAST
subcommands. -
KEEP
can be used to change the order of variables in the resulting file. WithKEEP
, variables are kept in the order in which they are listed on the subcommand. If a variable is named more than once onKEEP
, only the first mention of the variable is in effect; all subsequent references to that variable name are ignored. - The keyword
ALL
can be specified onKEEP
.ALL
must be the last specification onKEEP
, and it refers to all variables not previously named on that subcommand. It is useful when you want to arrange the first few variables in a specific order.
Example
ADD FILES FILE="/data/particle.sav" /RENAME=(PARTIC=pollute1)
/FILE="/data/gas.sav" /RENAME=(OZONE TO SULFUR=pollut2 TO pollute4)
/KEEP=pollute1 pollute2 pollute3 pollute4.
- The renamed variables are retained in the resulting
file.
KEEP
is specified after all theFILE
andRENAME
subcommands, and it refers to the variables by their new names.