<For example: a variable has values 1 2 3 5 10 11 12 13 14 20 21 .... I want to replace it with 1 2 3 4 5 6 7 8 9 10 11..... I was using this command but is not giving, the desired results: old variable=district I want to replace value with the correct sequential values>
levelsof district, local(district_new)
foreach i in `district_new'{
replace district= mod(_n-1,707)+1
}