* Apply a macro to every file whose name is in a sav file.SPS. * Apply a given macro to every file whose name is in a sav file. DATA LIST FIXED /id 1-2 (F) fname 3-22 (A). BEGIN DATA 1 employee data.sav 2 Fat surfactant.sav 3 flying.sav 4 Glass strain.sav END DATA. LIST. SAVE OUTFILE='c:\\temp\\list file names.sav'. * This is the given macro. *//////////. DEFINE !count(file=!CMDEND) COMPUTE xyz=1. SUMMARIZE /TABLES=xyz /FORMAT=NOCASENUM TOTAL /TITLE=!QUOTE(!CONCAT('Number of cases in file ',!file)) /MISSING=VARIABLE /CELLS=COUNT . !ENDDEFINE. *//////////. /* Write a syntax file which loads each file named in */ /* "list file names.sav" and calls the macro !count */ GET FILE='c:\\temp\\list file names.sav'. STRING fn(A50). COMPUTE fn=CONCAT("c:\\Program Files\\SPSS\\",fname). WRITE OUTFILE='c:\\temp\\do all files.sps' /'GET FILE="' fn '".' /'!count file='fname'.'. EXECUTE. SET MPRINT=yes. * Run the syntax file we just created. INCLUDE 'c:\\temp\\do all files.sps'.