* Initial file has category variable cat1 which has n different values. * Objective is to create n different files. * This creates a data file for illustration purposes. * The categorical variable cat1 has up to 10 different values. * The syntax works for any different values of cat1. * They do not have to be consecutive. * Raynald Levesque. NEW FILE. INPUT PROGRAM. LOOP id=1 TO 500. COMPUTE cat1=TRUNC(UNIFORM(10)). END CASE. END LOOP. END FILE. END INPUT PROGRAM. EXECUTE. SAVE OUTFILE='c:\\data\\mydata.sav'. * Now start the job. set mprint=on. *//////////////////////////////////////////. DEFINE !SPLIT (var=!TOKENS(1) /value=!TOKENS(1) ). TEMPORARY. SELECT IF (!var=!value). SAVE OUTFILE=!QUOTE(!CONCAT('c:\\data\\temp',!value,'.sav')). EXECUTE. !ENDDEFINE. *//////////////////////////////////////////. *Find all different value of cat1 which exists. AGGREGATE /OUTFILE=* /BREAK=cat1 /dummy = FIRST(id). FORMAT cat1(F8.0). * Write a syntax file which will call the above macro. WRITE OUTFILE='c:\\data\\temp.sps' / '!SPLIT var=cat1 value=' cat1 '.'. Execute. * Get the original data file and do the macro calls. GET FILE='c:\\data\\mydata.sav'. INCLUDE 'C:\\data\\temp.sps'.