Hi -
I'm trying to figure out why Stata (v14.1) seems to be added a bunch of extra non-sensical decimal places to my data. I'm working with Census Tract ID numbers, which are always either 4-digits long (i.e. XXXX) or 4 digits with two decimal places (XXXX.XX). When I ask Stata to "list" the tracts, they appear as normal, but when I look in the Data Editor I can see that, for example, Tract 4502.01 is actually being read by Stata as though it were an approximation for 4502.0098, and Tract 4507.41 is being read as though it were an approximation for 4507.4102 (pic attached to demonstrate what I mean). Note that none of my observations that are only 4 digits long have any issues, and this doesn't even affect all of the tracts with decimal places, just a handful of tracts at random is seems. [Edit: I've triple-checked the original data and these decimal places are not present, so this is clearly happening only after I import the data into Stata.]
So my first question is why Stata is taking creative license with my data, and how I should go about telling Stata to stop.
I have tried converting the variable from a float to a string, thinking maybe that would accomplish something -- no dice. I still have garbage decimal places.
I've also tried circumventing this problem altogether by trying to import the variable (which came from a .csv file) as a string variable rather than as a float, but being a novice I'm struggling to figure out how to do this using the "stringcols" option. I tried using the following....
import delimited using "\\Client\C$\Users\Heather\Desktop\Tax base capacity trial\Raw Crosswalk Data.csv", stringcols(4)
....thinking that because the field that I want to be imported as a string is the 4th field in the dataset that I should be specifying the number 4... but having reviewed the result this is obviously not how it's done and I can't seem to find any examples online of how to properly use the stringcols option. My second question is therefore how to import .csv data with some fields as strings.
Thanks!
-Heather
I'm trying to figure out why Stata (v14.1) seems to be added a bunch of extra non-sensical decimal places to my data. I'm working with Census Tract ID numbers, which are always either 4-digits long (i.e. XXXX) or 4 digits with two decimal places (XXXX.XX). When I ask Stata to "list" the tracts, they appear as normal, but when I look in the Data Editor I can see that, for example, Tract 4502.01 is actually being read by Stata as though it were an approximation for 4502.0098, and Tract 4507.41 is being read as though it were an approximation for 4507.4102 (pic attached to demonstrate what I mean). Note that none of my observations that are only 4 digits long have any issues, and this doesn't even affect all of the tracts with decimal places, just a handful of tracts at random is seems. [Edit: I've triple-checked the original data and these decimal places are not present, so this is clearly happening only after I import the data into Stata.]
So my first question is why Stata is taking creative license with my data, and how I should go about telling Stata to stop.
I have tried converting the variable from a float to a string, thinking maybe that would accomplish something -- no dice. I still have garbage decimal places.
I've also tried circumventing this problem altogether by trying to import the variable (which came from a .csv file) as a string variable rather than as a float, but being a novice I'm struggling to figure out how to do this using the "stringcols" option. I tried using the following....
import delimited using "\\Client\C$\Users\Heather\Desktop\Tax base capacity trial\Raw Crosswalk Data.csv", stringcols(4)
....thinking that because the field that I want to be imported as a string is the 4th field in the dataset that I should be specifying the number 4... but having reviewed the result this is obviously not how it's done and I can't seem to find any examples online of how to properly use the stringcols option. My second question is therefore how to import .csv data with some fields as strings.
Thanks!
-Heather
Comment