1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
* Calculate the number of different values within each case.

* Posted by Allen Reese <r.a.reese@gri.hull.ac.uk>
 to SPSSX-L on 2001/03/19.

DATA LIST LIST /subj  Sport1  Sport2  Sport3  Sport4  Sport5  Sport6.
BEGIN DATA
1   1       5       6       7       30      12     
2   1       1       23      6                      
3   3       7       45      45      15             
4   6       6       12      12                     
END DATA.
LIST.

vector ss(55,f2.0).
do repeat sport=sport1 to sport6.
if (sport>0 and sport<56) ss(sport)=1.
end repeat.
compute nsports=0.
loop #N=1 to 55.
if ( ss(#N) = 1 ) nsports=nsports+1.
end loop.
MATCH FILES FILE=* /BY=subj /DROP=ss1 to ss55.
execute.