See LAG function.
IF $CASENUM EQ 1 New_ID=1.
IF ID EQ LAG(ID) New_ID=LAG(New_ID) .
IF MISSING(New_ID) New_ID=LAG(New_ID) + 1.
OR:
COMPUTE New_ID=SUM(LAG(New_ID),MAX(ID NE LAG(ID), $CASENUM EQ 1)).
HTH.
---
sb wrote
Hello,
I have a dataset with case ID's that are unique to the project, which need to be kept. However, there are cases that have the same ID, which also need to be kept. I want to create a new id that will number the cases 1 - 4000, however, utilize the same ID for the duplicates. This would show the total number of cases, not including duplicates.
For example:
ID New ID
x20 1
x25 2
x30 3
x30 3
x30 3
x35 4
x40 5
Any suggestions on how to do this easily with syntax? I have 4000 cases & would prefer to not do it by hand & avoid any mistakes.
Thanks!
-Sherah
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"