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
> > Date:         Thu, 23 May 1996 17:28:03 -0500
> > Reply-To:     David Marso <marso@SPSS.COM>
> > Sender:       "SPSSX(r) Discussion" <SPSSX-L@UGA.CC.UGA.EDU>
> > From:         David Marso <marso@SPSS.COM>
> > Organization: SPSS Inc
> > Subject:      Re: (no subject given) COMPARING SYSTEM FILES

Duanren Yuan wrote:
>
>      Dear SPSS netter,
>
>      Would you help me solve the problem. I asked two persons to do data
>      entry. They used the same set of questionnaires. I want to check
>      whether each value in the two data files are exactly the same by using
>      SPSS program. How Can I do that? Any suggestion will be very much
>      appreciated.
>
>      Jeremy Yuan




* Sample data files * .
DATA LIST /ID (F1) NX NY NZ (3F1) SX SY SZ (3A1).
BEGIN DATA
1124ABC
2245SEF
3234DFG
END DATA.
SAVE OUTFILE 'F1'.

DATA LIST /ID (F1) NX NY NZ (3F1) SX SY SZ (3A1).
BEGIN DATA
1123ABC
2345SEF
3234DFH
END DATA.
SAVE OUTFILE 'F2'.

* Assuming your files are sorted by ID,  have ID's which match,
the variables are the same (String lengths are the same etc) *.

ADD FILES FILE 'F1' / IN=ONE / FILE='F2' / IN=TWO / BY ID .
DO IF TWO.
DO REPEAT V=NX NY NZ SX SY SZ /TAG=TNX TNY TNZ TSX TSY TSZ.
COMPUTE TAG=(V<>LAG(V)).
END REPEAT.
END IF.
COMPUTE DIFF=SUM(TNX TO TSZ).
FORMATS TNX TNY TNZ TSX TSY TSZ (F1).
LIST.

ID NX NY NZ SX SY SZ ONE TWO TNX TNY TNZ TSX TSY TSZ     DIFF

 1  1  2  4 A  B  C   1   0   .   .   .   .   .   .       .
 1  1  2  3 A  B  C   0   1   0   0   1   0   0   0      1.00
 2  2  4  5 S  E  F   1   0   .   .   .   .   .   .       .
 2  3  4  5 S  E  F   0   1   1   0   0   0   0   0      1.00
 3  2  3  4 D  F  G   1   0   .   .   .   .   .   .       .
 3  2  3  4 D  F  H   0   1   0   0   0   0   0   1      1.00