How To Create a Unique ID from an ID Variable That Contains Duplicates

This page explains how to use JavaScript to create a unique ID variable from an ID variable that contains some repeated values. In some cases the data file may be missing a variable which identifies each respondent uniquely, because some respondents have data in more than one row of the file, but there is still a need to have a variable which identifies the cases uniquely (for example to set the Case IDs in the Data tab). Here, we make a new variable where each occurrence of an ID value after the first has a number appended to it. For example, if the ID 100355 appears twice, the new variable will have values of 100355 and 100355_1 in the corresponding rows. This process requires you to make a new copy of your SPSS data file.