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
* This macro is useful when you need to remove duplicate values
	within the same case.
* For instance in the data below, the 3rd case has 11 in variable c and d.
* By default, a new variable named 'miss' flags the cases with no values for
	the variables listed in the macro call. A different name for that 
	variable can be specified with the parameter zm.
* Macro sent to Ray by Maciek Lobinski on 2002/05/24.

data list list /a b c d.
begin data
5 7 0 0
5 9 10 5
5 7 11 11
6 7 10 8
6 7 13 4
5 7 9 6
1 13 14 1
 . . .
1 7 13 1
2 2 2 7
end data.


define duble (!positional= !charend('|')
 /zm =!default(miss) !charend('|')) .

!let !ciag=''.
!let !jeden=''.
!let !dwa=''.
recode !1 (0=sysmis).

!do !i !in (!1).
!let !jeden=(!i).
!do !j !in (!1).
!let !dwa=(!j).
!if (!jeden<>!dwa) !then
if (!i=!j) !j=$sysmis.
!ifend.
!doend.
!doend.

!do !i !in (!1).
!let !ciag=!concat(!ciag,',',!i).
!doend.
!let !ciag=!tail(!ciag).
if (nvalid(!ciag)=0) !zm=0.
value labels /!zm 0'missing case'.

!enddefine.


*example.
duble a b c d.

*or.
duble a b c d |zm=myvar.