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
* macros_many_files_combine04.sps.
* Add any number of consecutively named files, 50 files at a time.

*////////////.
DEFINE !merge4 (path=!TOKENS(1) /stem=!TOKENS(1) /n1=!TOKENS(1) /n2=!TOKENS(1))

!DO !cnt=!n1 !TO !n2 !BY 49

  !IF (!cnt=!n1) !THEN 
    !LET !inifile=!QUOTE(!CONCAT(!UNQUOTE(!path),!UNQUOTE(!stem),!n1,'.sav')) 
  !ELSE 
    !LET !inifile='*'
  !IFEND

  !LET !cnt2=!LENGTH(!CONCAT(!BLANK(!cnt),!BLANK(48)))
  !IF (!BLANK(!cnt2) !GT !BLANK(!n2)) !THEN !LET !cnt2=!n2 !IFEND

ADD FILES FILE=!inifile
  !DO !fn=!cnt !TO !cnt2 /FILE=!QUOTE(!CONCAT(!UNQUOTE(!path),!UNQUOTE(!stem),!fn,'.sav')) !DOEND.

!DOEND
SAVE OUTFILE=!path + 'master.sav'.
!ENDDEFINE.
*////////////.

SET MPRINT=yes.
* Merge files file2 to file60.
!merge4 path="c:\\temp\\" stem=file n1=2 n2=60.