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
*(Q) How can I number cases (with the same id) from 1 to the number of cases with that id?

*(A) By Ray 2002/05/15.


DATA LIST LIST /sub# dv.
BEGIN DATA
1		33
1		53
1		42
1		38
2		65
2		47
3		34
3		46
4		49
END DATA.
LIST.


COMPUTE caseid=$CASENUM.
RANK VARIABLES=caseid BY sub#  /RANK INTO trl#.
LIST.

Output:
    SUB#       DV   CASEID      TRL#

    1.00    33.00     1.00     1.000
    1.00    53.00     2.00     2.000
    1.00    42.00     3.00     3.000
    1.00    38.00     4.00     4.000
    2.00    65.00     5.00     1.000
    2.00    47.00     6.00     2.000
    3.00    34.00     7.00     1.000
    3.00    46.00     8.00     2.000
    4.00    49.00     9.00     1.000