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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
* QUESTIONS: How can I get two random samples having the same age, sex and education parameters?
*
* ANSWER by Raynald@spsstools.net
*.

DATA LIST LIST /id age sex educ.
BEGIN DATA
1	25	1	10
2	25	1	12
3	25	1	12
4	25	2	10
5	25	2	10
6	25	2	12
7	25	1	12
8	26	1	10
9	26	1	10
10	26	1	12
11	26	2	10
12	26	2	10
13	26	2	10
14	26	1	12
15	26	2	12
16	26	2	12
17	25	1	10
18	25	1	10
19	26	1	12
20	25	2	12
21	25	2	10
22	25	2	12
23	26	1	10
24	26	2	12
25	25	1	10
26	25	1	12
27	25	1	12
28	25	2	10
29	25	2	10
30	25	2	12
31	25	1	12
32	26	1	10
33	26	1	10
34	26	1	12
35	26	2	10
36	26	2	10
37	26	2	10
38	26	1	12
39	26	2	12
40	26	2	12
41	25	1	10
42	25	1	10
43	26	1	12
44	25	2	12
45	25	2	10
46	25	2	12
47	26	1	10
48	26	2	12
END DATA.

* Replace the numbers in next line by your criterias.
SELECT IF ((sex=1)&(age=25)&(educ=10)).
COMPUTE draw=UNIFORM(1).
SORT CASES BY draw.

* Replace the 2 in next line by the size of your sample; keep the .5).
COMPUTE sample=TRUNC($casenum/(2.5)).
SELECT IF sample<2.

* The cases with the sample=0 form your first random sample.
* The cases with the sample=1 form your second random sample.