Examples (UPDATE command)

Basic Example

UPDATE FILE='/data/mailist.sav' 
  /FILE='/data/newlist.sav' 
  /BY=ID.
  • mailist.sav is specified as the master file. newlist.sav is the transaction file. ID is the key variable.
  • Both mailist.sav and newlist.sav must be sorted in ascending order of ID.
  • If newlist.sav has cases or nonmissing variables that are not in mailist.sav, the new cases or variables are added to the resulting file.

Using Multiple Key Variables

SORT CASES BY LOCATN DEPT.
UPDATE  FILE='/data/master.sav' /FILE=* /BY LOCATN DEPT
  /KEEP AVGHOUR AVGRAISE LOCATN DEPT SEX HOURLY RAISE /MAP.
SAVE OUTFILE='/data/personnel.sav'.
  • SORT CASES sorts the active dataset in ascending order of the variables to be named as key variables on UPDATE.
  • UPDATE specifies master.sav as the master file and the sorted active dataset as the transaction file. The file master.sav must also be sorted by LOCATN and DEPT.
  • BY specifies the key variables LOCATN and DEPT.
  • KEEP specifies the subset and order of variables to be retained in the resulting file.
  • MAP provides a list of the variables in the resulting file and the two input files.
  • SAVE saves the resulting file as a data file in IBM® SPSS® Statistics format.