* QUESTION: I want to split a file in two random pieces. I want to do this n times and keep track of all the n splits in the same data file. * ASNWER by Ray. * www.spsstools.net *. SET MPRINT=no. * Create dummy data for illustration purposes. NEW file. input program. loop id_org=1 to 10. leave id_org. COMPUTE #nb_ees=4+TRUNC(UNIFORM(10)). loop id_ee=1 to #nb_ees. + compute dept=1+TRUNC(uniform(5)). + end case. end loop. end loop. end file. end input program. execute. SAVE OUTFILE='c:\\temp\\temp.sav'. * Define macro. *///////////////////////////////. DEFINE !do_job (n_samp=!TOKENS(1)) !DO !cnt=1 !TO !n_samp. GET FILE='c:\\temp\\temp.sav'. COMPUTE randval = UNIFORM(1). SORT CASES BY id_org randval. COMPUTE seqnum = $casenum. COMPUTE choose1 = MOD(seqnum,2). /*do your analysis here*/. SAVE OUTFILE=!QUOTE(!CONCAT('c:\\temp\\data',!cnt,'.sav')). !DOEND !ENDDEFINE. *///////////////////////////////. SET MPRINT=yes. * Call macro. !do_job n_samp=3. * set n_samp equal to the desired number of samples.