3

I have a SPSS dataset with information of different household members and I need to generate a new variable that counts the number of people that compose each one of these households.The original dataset is something like:

ID | age | height

332 | 23 | 1.78

332 | 27 | 1.65

344 | 56 | 1.79

344 | 34 | 1.98

344 | 15 | 1.58

etc... and I need to generate a new variable that counts the id repetitions such as 'n' in:

ID | age | height | n

332 | 23 | 1.78 | 2

332 | 27 | 1.65 | 2

344 | 56 | 1.79 | 3

344 | 34 | 1.98 | 3

344 | 15 | 1.58 | 3

Is there any straightforward way to do it with window commands or do I need to use command language?

Jignesh Sutar
  • 2,909
  • 10
  • 13
vabm
  • 285
  • 7
  • 16

1 Answers1

1

Look up the AGGREGATE command.

AGGREGATE OUTFILE=* MODE=ADDVARIABLES /BREAK=ID /Count=N.
Jignesh Sutar
  • 2,909
  • 10
  • 13