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
*(Q).
Is there a way I can detect ties for any
value in any of the variables?  So, in the end, we would have 1 variable
that is flagged for a tie in at least one pair (1) or not flagged (0).  The
reason I say this is because my variables have values all over the place
like 7.1439583 or 12.93878974.  A complication is that the part in parentheses at the end of the COUNT
command will not accept a variable instead of a number.  Any ideas?

*(A) Posted to SPSSX-L by Raynald Levesque on 2002/10/30.
* Note: This is a treat for *macro lovers*.

DATA LIST LIST /var1 var2 var3 var4.
BEGIN DATA
1 2 3 3
1 2 3 4
1 1 2 2
1 1 1 1
3 3 2 2
. . 1 2
4 1.7 2 1.7
END DATA.
LIST.

* Flag any cases where some of the variables have the same value.

*////////////////////.
DEFINE !test(listvar=!CMDEND)

!IF (!listvar !NE !NULL) !THEN
 !LET !testval=!HEAD(!listvar)
 !LET !other=!TAIL(!listvar)
 !DO !var !IN (!other)
-  COMPUTE flag=SUM(!var = !testval, flag).
 !DOEND
!test listvar=!other.
!IFEND

!ENDDEFINE.
*////////////////////.

SET MPRINT=yes.
COMPUTE flag=0.
!test listvar=var1 var2 var3 var4.
SET MPRINT=no.
COMPUTE flag2=MIN(flag,1).
EXECUTE.

* Flag2 = 1 when any of the variables var1 to var4 have the same value.