1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
* How can I obtain n independant random samples of size m from the same file?

* Answer posted to SPSSX-L by Raynald Levesque rlevesque@videotron.ca on 2001/04/14.
* www.spsstools.net

PRESERVE.
SET MPRINT=yes.
*///////////////////////////////.
DEFINE !getsamp (nbcases=!TOKENS(1) /nbfiles=!TOKENS(1) )

!DO !var=1 !TO !nbfiles
GET FILE='C:\\Program Files\\SPSS\\GSS93 subset.sav'.
COMPUTE draw=UNIFORM(1).
COMPUTE dummy=1.
RANK VARIABLES=draw BY dummy  /RANK INTO rank1.
SELECT IF rank1 LE !nbcases.
SAVE OUTFILE=!QUOTE(!CONCAT("c:\\Temp\\new file ",!var,".sav")).
!DOEND
!ENDDEFINE.
*///////////////////////////////.

*Next line starts the whole process.
!getsamp nbcases=300 nbfiles=4.
RESTORE.