I have a SAS dataset with an ID variable which is supposed to be unique at the person level, but in reality there are duplicates. What I'd like to do is create a duplicate ID which only fills when a person has duplicate values of ID, like this:
ID Dupe_ID
1
2 1
2 1
3
4 2
4 2
Any help is much appreciated!
It's handling it slightly differently, but just in case it's of use to you and/or others -
proc sort
has a handy simpledupout=
option for seperating out non-unique key observations:The first occurence of each
id
will go to thewant
dataset. Any subsequent observations with the sameid
will go to thedups
dataset