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 and KEEP do not affect the input files on disk.
  • DROP and KEEP must follow all FILE and RENAME subcommands.
  • DROP and KEEP must specify one or more variables. If RENAME is used to rename variables, specify the new names on DROP and KEEP.
  • DROP cannot be used with variables created by the IN subcommand.
  • The keyword ALL can be specified on KEEP. ALL must be the last specification on KEEP, and it refers to all variables not previously named on KEEP.
  • KEEP can be used to change the order of variables in the resulting file. With KEEP, variables are kept in the order in which they are listed on the subcommand. If a variable is named more than once on KEEP, only the first mention of the variable is in effect; all subsequent references to that variable name are ignored.
  • Multiple DROP and KEEP subcommands are allowed. Specifying a variable that is not in the active dataset or that has been dropped because of a previous DROP or KEEP subcommand results in an error and the UPDATE 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 on KEEP.