I would like to generate a new ID variable, which is based on ID1 and ID2. Instead of giving the unique ID after sorting, I wanted to use the below way, and its advantage is that I can keep both IDs in id12. But the code doesn't work as I expect. id12 for the first observation is supposed to be 135205439, not 135205440. I hope that there is a simple fix for this.
Code:
clear
input id1 id2
1352 5439
5386 9615
4359 8139
end
gen id12= id1*10^5 + id2
format id* %16.0f
list
| id1 id2 id12 |
|-------------------------|
1. | 1352 5439 135205440 |
2. | 5386 9615 538609600 |
3. | 4359 8139 435908128 |

Comment