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
69
70
71
72
73
74
75
76
* solution from SPSS's AnswerNet,
* http://www.spss.com/tech/answer/result.cfm?tech_tan_id=100000493 .

*Title: Error checking with syntax
   Description:
*(Q)
*   I have had two operators enter the same data in two files.
*   How do I get SPSS to check the two files for discrepancies?

*(A).
* Assume 2 presumably identical files of N variables each.

* Rename vars in 1 file and merge with 2nd file.

 do repeat v=var_1 to var_n
   /w=var_n+1 to var_n+n
   /e=err_1 to err_n.
 if (v ne w) e=1.
 end repeat.
 compute newvar=sum(err_1 to err_n).
 Select if (newvar>=1).

* The resulting cases are problematic ones. Compare variable
* information to original responses and correct your dataset.
* If no cases result, data entry was consistent across operators.

* Here is a syntax job that will illustrate:

 * This syntax creates the two example files.
 * DO NOT USE THIS PART IN YOUR SYNTAX.
 input program.
 loop.
 do repeat #r=var_1 to var_10.
 compute #r=trunc (uniform(5))+1.
 end repeat.
 end case.
 end loop.
 end file.
 end input program.
 exe.
 compute id=$casenum.
 save outfile = '@first@.sav'.
 exe.
 If (var_1=5) var_10=3.
 save outfile = '@second@.sav'.
 exe.

 * This syntax and all after you should use.
 * This syntax merges the files and renames variables.
 match files file=*
   /file='@first@.sav'
   /rename (var_1 to var_10 = var_11 to var_20)
   /by id.
 exe.

 * This syntax does the error checking.
 do repeat v=var_1 to var_10
   /w=var_11 to var_20
   /e=err_1 to err_10.
 if (v ne w) e=1.
 end repeat.
 exe.

 *This syntax creates a new file that has only ID
 * and the error variables.

 * Use this file to check your data for transcription errors.
 compute newvar=sum(err_1 to err_10).
 select if (newvar>=1).
 save outfile = '@third@.sav'
  /keep id err_1 to err_10.
 exe.
 get file '@third@.sav'.
 exe.

*   Created on: 10/22/2000 "