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.
-
DROPandKEEPdo not affect the input files on disk. -
DROPandKEEPmust follow allFILEandRENAMEsubcommands. -
DROPandKEEPmust specify one or more variables. IfRENAMEis used to rename variables, specify the new names onDROPandKEEP. -
DROPandKEEPtake effect immediately. If a variable specified onDROPorKEEPdoes not exist in the input files, was dropped by a previousDROPsubcommand, or was not retained by a previousKEEPsubcommand, the program displays an error message and does not execute theADD FILEScommand. -
DROPcannot be used with variables created by theIN,FIRST, orLASTsubcommands. -
KEEPcan 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
ALLcan be specified onKEEP.ALLmust 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.
KEEPis specified after all theFILEandRENAMEsubcommands, and it refers to the variables by their new names.