SPSS Statistics commands to merge files
For a one-to-one merge, use MATCH FILES
. The basic general form is as follows:
MATCH FILES FILE=file1/FILE=file2/BY key_variable
While this example is for two files, MATCH FILES
can merge up to 50 files at a time. MATCH FILES
can perform a parallel match in which records from each file align sequentially. MATCH FILES
can also perform a nonparallel match in which records are matched when key variables are equal.
Note that there are additional subcommands and features documented in IBM SPSS Statistics Help. You can keep variables, drop variables, rename variables, and produce a variable map, among other things.
In order for MATCH FILES
to work correctly, all source files must be sorted in ascending order on the key variables. As MATCH FILES
is not a procedure, you must follow it with either a procedure or the EXECUTE
command.
For a one-to-many merge, you could also use MATCH FILES
. The basic general form is as follows:
MATCH FILES FILE=file1/TABLE=file2/BY...