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.
-
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. -
DROPcannot be used with variables created by theINsubcommand. - The keyword
ALLcan be specified onKEEP.ALLmust be the last specification onKEEP, and it refers to all variables not previously named onKEEP. -
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. - Multiple
DROPandKEEPsubcommands are allowed. Specifying a variable that is not in the active dataset or that has been dropped because of a previousDROPorKEEPsubcommand results in an error and theUPDATEcommand 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.
-
KEEPspecifies the variables to keep in the result file. The variables are stored in the order specified onKEEP.