Reputation: 285
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?
Upvotes: 3
Views: 1142
Reputation: 2929
Look up the AGGREGATE command.
AGGREGATE OUTFILE=* MODE=ADDVARIABLES /BREAK=ID /Count=N.
Upvotes: 1