Reputation: 41
I have a person identification number variable in a panel dataset that is of string type with 19 characters (str19
). Whenever I convert it into numeric using the destring
command I lose precision because it is converted into either double
(max 16 characters) or float
, meaning that the ID numbers no longer identify respondents uniquely. I need it to be numeric in order to treat the data as panel (xt
commands). What can I do?
Upvotes: 2
Views: 455
Reputation: 37208
The best way forward I can think of is to use egen
's group()
function to create identifiers. You don't provide a data or code example, but this illustrates the point.
. clear
. set obs 1
number of observations (_N) was 0, now 1
. gen strid = "1234567890123456789"
. egen numid = group(strid), label
. list
+-------------------------------------------+
| strid numid |
|-------------------------------------------|
1. | 1234567890123456789 1234567890123456789 |
+-------------------------------------------+
. list, nolabel
+-----------------------------+
| strid numid |
|-----------------------------|
1. | 1234567890123456789 1 |
+-----------------------------+
Note that this is documented: see this FAQ.
Upvotes: 1