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
*(Q) How can I find invalid entries in my data file.

*(A) Raynald Levesque on 2002/07/28.

DATA LIST LIST /id var1 var2 var3.
BEGIN DATA
1 2 8 14.23
2 3 4 9.21
3 5 1 14
4 0 2 13.26
END DATA.
SAVE OUTFILE='c:\\temp\\temp.sav'

* Suppose the valid entries for var1 and var2 are 1, 2,3,4 & 5.
* and the valid entries for var are any number between 10 and 15.

*The following syntax flags the incorrect entries.
DO REPEAT flag=flag1 flag2
	/var=var1 var2.
COMPUTE flag=~ANY(var,1,2,3,4,5).
END REPEAT.

COMPUTE flag3=~RANGE(var3,10,15).

EXECUTE.
SELECT IF SUM(flag1 TO flag3)>0.
LIST.

*The result of the liss command is:
      ID     VAR1     VAR2     VAR3    FLAG1    FLAG2    FLAG3

    1.00     2.00     8.00    14.23      .00     1.00      .00
    2.00     3.00     4.00     9.21      .00      .00     1.00
    4.00      .00     2.00    13.26     1.00      .00      .00


Number of cases read:  3    Number of cases listed:  3

Flag2 =1 means that case 1 has an incorrect value for var2.
Flag3 =1 means that case 2 has an incorrect value for var3.
Flag1 =1 means that case 4 has an incorrect value for var1.