1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
* How can I combine many files with the same variables.
* files are called file1991 to file1998.

* Answer by Ray.

***************DEFINE MACRO **********************.
DEFINE !merge ().

* Get the first file.
GET
  FILE='C:\\Program Files\\SPSS\\test\\file1991.sav'.
COMPUTE file1991=1.
FORMATS file1991(F8).

* Add all the other files to it.
!DO !var=1992 !TO 1998.
ADD FILES /FILE=*
 /FILE=!QUOTE(!CONCAT("c:\\Program Files\\SPSS\\test\\file",!var,".sav"))
 /IN=!CONCAT(file,!var).
VARIABLE LABELS !CONCAT(file,!var) !QUOTE(!var).
EXECUTE.
!DOEND.

!ENDDEFINE.
*************END OF MACRO ************************.

*call macro.
!merge.