DROP and KEEP Subcommands (UPDATE command)
DROP
and KEEP
are used to include 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
cannot be used with variables created by theIN
subcommand. - The keyword
ALL
can be specified onKEEP
.ALL
must be the last specification onKEEP
, and it refers to all variables not previously named onKEEP
. -
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. - Multiple
DROP
andKEEP
subcommands are allowed. Specifying a variable that is not in the active dataset or that has been dropped because of a previousDROP
orKEEP
subcommand results in an error and theUPDATE
command is not executed.
Example
UPDATE FILE='/data/mailist.sav' /FILE='/data/newlist.sav' /RENAME=(STREET=ADDRESS)
/BY ID /KEEP=NAME ADDRESS CITY STATE ZIP ID.
-
KEEP
specifies the variables to keep in the result file. The variables are stored in the order specified onKEEP
.