I believe that I've read an explanation for this at some point, but I can't find it, so if someone knows where it's explained, I'd appreciate a nudge in that direction.
The issue I'm running into deals with creating new variables and how Stata decides which variable type to assign them. I'm using a variable of long numeric identifiers and the issue can be seen like this.
If I then go into the data editor and look at the values:
The values are not the same and x is a float and y is a long
If I then go
z is a float equal to 1,366,548,224, which obviously isn't the number I want.
My question is how does Stata decide which numeric type to use when generating new variables without specifying what type to be used? My challenge came because I assumed that Stata would generate z as a long (like y is) but instead generates it as a float. Also, when it generates the float, why does the number change from what I typed in? Since these are identifiers, the change of a single digit is very problematic. I finally figured out the issue for my current project, but I'd be interested in knowing what is happening behind the curtain for future reference.
The issue I'm running into deals with creating new variables and how Stata decides which variable type to assign them. I'm using a variable of long numeric identifiers and the issue can be seen like this.
Code:
clear set obs 1 gen x = 1366548281 gen long y = 1366548281 format %15.0gc x y
x | y |
1,366,548,224 | 1,366,548,281 |
If I then go
Code:
gen z = y format %15.0gc z
My question is how does Stata decide which numeric type to use when generating new variables without specifying what type to be used? My challenge came because I assumed that Stata would generate z as a long (like y is) but instead generates it as a float. Also, when it generates the float, why does the number change from what I typed in? Since these are identifiers, the change of a single digit is very problematic. I finally figured out the issue for my current project, but I'd be interested in knowing what is happening behind the curtain for future reference.
Comment