Let’s suppose that you have a variable that counts how many cases you have in each group. Now what you need is a variable that consecutively numbers these groups. Below is the syntax to create the group variable.
data list list / a. begin data. 1 2 3 1 2 3 4 1 2 3 4 5 6 1 2 1 2 3 end data. compute #x = #x + 1. if a ne 1 #x = lag(#x). compute x = #x. exe. list.
a x
1.00 1.00
2.00 1.00
3.00 1.00
1.00 2.00
2.00 2.00
3.00 2.00
4.00 2.00
1.00 3.00
2.00 3.00
3.00 3.00
4.00 3.00
5.00 3.00
6.00 3.00
1.00 4.00
2.00 4.00
1.00 5.00
2.00 5.00
3.00 5.00
Number of cases read: 18 Number of cases listed: 18
