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
* Say want to compare those with pathological cholest (cholest=1) with those with normal cholesterol (cholest=0).
* Want to pair each patho case with a normal case having the same characteristics.
* Posted by rlevesque@videotron.ca to spss usenet on April 20,2000.

**** This section creates dummy data for illustration purposes.

NEW file.
input program.
SET SEED=246813579.
loop caseid=1 to 200.
leave caseid.

compute age=RND(uniform(4)).
COMPUTE gender=UNIFORM(1)>.5.
COMPUTE bloodpr=RND(UNIFORM(4)).
COMPUTE diab=UNIFORM(1)>.5.
COMPUTE cholest=UNIFORM(1)>.5.
FORMATS caseid TO cholest (F8.0).
end case.
end loop.
end file.
end input program.
execute.

*** This section does the job.


*Create the comparative criteria (I assume the variables have values between 0 and 9).
COMPUTE criter=age+gender*10+bloodpr*100+diab*1000.
COMPUTE draw=UNIFORM(1).
SORT CASES BY cholest criter.
RANK
  VARIABLES=draw  (A) BY cholest criter  /RANK /PRINT=YES
  /TIES=MEAN .

SORT CASES BY criter rdraw.
COMPUTE criter2=criter*1000+rdraw.
SAVE OUTFILE='c:\\temp\\all_data.sav'.
SELECT IF (cholest=0).
SAVE OUTFILE='c:\\temp\\normal pop.sav'.

GET FILE='c:\\temp\\all_data.sav'.
SELECT IF (cholest=1).
RENAME VARIABLES (caseid=caseid1) (age=age1) (gender=gender1) (bloodpr=bloodpr1) (diab=diab1) (rdraw=rdraw1).
SAVE OUTFILE='c:\\temp\\pathological pop.sav'.

MATCH FILES /FILE=*
 /TABLE='c:\\temp\\normal pop.sav'
 /RENAME (cholest = d0)
 /BY criter2
 /DROP= d0.

*Keep only cases where there is a match.
SELECT IF ~MISSING(caseid).