Dear All,

I wanted to know how we can identify duplicate serial number within an EA and assign a unique serial number which is not there within that EA. For example the unique code should be the combination of dcode gtcode clcode EA and slno. So for example if in 1 1 1 0 there are three serial number 10 in the example below. I want to replacce them as 10,11 and 12 since these are the numbers missing. For the second EA 1 1 2 0 there are 3 cases with slno 2 i want to replace it with 2, 6 and 7 since these are the missing slno. Below is an example of my part of my dataset. There are about 700 duplicates so I want to know an easier way to generate unique slno. For the EA with no duplicate i want to keep it as it is

Thank you

----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte(dcode gtcode) str3(clcode EA) byte slno
1 1 "1" "0"  1
1 1 "1" "0"  2
1 1 "1" "0"  3
1 1 "1" "0"  4
1 1 "1" "0"  5
1 1 "1" "0"  6
1 1 "1" "0"  7
1 1 "1" "0"  8
1 1 "1" "0"  9
1 1 "1" "0" 10
1 1 "1" "0" 10
1 1 "1" "0" 10
1 1 "2" "0"  1
1 1 "2" "0"  2
1 1 "2" "0"  3
1 1 "2" "0"  4
1 1 "2" "0"  5
1 1 "2" "0"  2
1 1 "2" "0"  2
1 1 "2" "0"  8
1 1 "2" "0"  9
1 1 "2" "0" 10
1 1 "2" "0" 11
1 1 "2" "0" 12
1 1 "3" "0"  1
1 1 "3" "0"  2
1 1 "3" "0"  3
1 1 "3" "0"  3
1 1 "3" "0"  5
1 1 "3" "0"  6
end
label values dcode dcode
label def dcode 1 "Bumthang", modify