Hi, all, I have trouble with some IDs before (and after..) a merger.
I want to 'mirror' and ID variable, so I can later have the same name across several files (MRNs), yet still preserve the initial ones.
So I generate a new variable

gen MRNs = iddrug

which shows this:

iddrug MRNs
134217752 1.34e+08
134217781 1.34e+08
134217786 1.34e+08
134217821 1.34e+08

The initial one has:
Type: long
Format: %12.0g

whereas the new one comes out as:
Type: float
Format: %9.0g

So: wouldn't the new one be expected to take on all the characteristics of the original variable?

If I try to revert its format with
format %12.0g MRNs

the numbers get 'scrambled':

iddrug MRNs
134217752 134217760
134217781 134217776
134217786 134217792
134217821 134217824

Any guess why this happens and how to 'fix' it?

Update before posting: I read some older posts and saw an option to generate this new one instead using
gen byte MRNs
replace MRNs=iddrug

which makes it come out as

Type: long
Format: %8.0g

and then with a
format %12.0g MRNs

seems to give me the right/same numbers:

iddrug MRNs
134217752 134217752
134217781 134217781
134217786 134217786
134217821 134217821

So: the remaining issue is why would gen mess up things in the first place (I need to watch my back from now on any time I use it... which isn't quite comforting).

Thanks, Emil