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
* id is the id of the library. Wants to sample libraries with the prob of picking a 
given library being proportional to its number of employees. 
* This Method will never select a library more times than it has employees.
* Raynald Levesque Raynald@spsstools.net .

DATA LIST FREE / id numb .
BEGIN DATA
1 5 2 15 3 30
END DATA.

* Next loop 'expands' the data file.
LOOP cnt=1 TO numb.
	XSAVE OUTFILE='c:\\temp\\temp.sav' /KEEP id numb.
END LOOP.
EXECUTE.

GET
  FILE='c:\\temp\\temp.sav'.

COMPUTE draw=UNIFORM(1).
RANK
  VARIABLES=draw  (A) /RANK /PRINT=NO
  /TIES=MEAN .

* In next line, replace 30 by the desired sample size.
SELECT IF (rdraw<=30).
EXECUTE.