I'm importing data into Stata from text files, and have found that some of the cases are shifted in the dataset once everything is in Stata. For example, I am importing 6 columns/variables labeled: ID, ZIP, DOB, SEX, LIC_ID, YEAR. Most cases imported perfectly, but some are shifted so that when I use the code:
tab SEX ---- > the results shows that some of the LIC_ID and DOB values have shifted into this column. This carries over to the other variables too - for ~3,000 / 1 million cases the values have shifted over.
The import code I've tried using:
First way:
import delimited "filepathname", delimiter(space, collapse) bindquote(strict) varnames(1) asfloat clear
Second way:
import delimited "filepathname", delimiter(space, collapse) bindquote(strict) varnames(1) numericcols(1 2 5 6) asfloat clear
I was using the second way to specify certain variables imported as numerics, not strings, but besides this result both files imported exactly the same with the "bumped over" values.
When I go back and look over the original text file, there are some missing cases (for example - "ZIP" has been left blank for some records) so I see how this could be happening, but I'm not sure how to remedy it.
tab SEX ---- > the results shows that some of the LIC_ID and DOB values have shifted into this column. This carries over to the other variables too - for ~3,000 / 1 million cases the values have shifted over.
The import code I've tried using:
First way:
import delimited "filepathname", delimiter(space, collapse) bindquote(strict) varnames(1) asfloat clear
Second way:
import delimited "filepathname", delimiter(space, collapse) bindquote(strict) varnames(1) numericcols(1 2 5 6) asfloat clear
I was using the second way to specify certain variables imported as numerics, not strings, but besides this result both files imported exactly the same with the "bumped over" values.
When I go back and look over the original text file, there are some missing cases (for example - "ZIP" has been left blank for some records) so I see how this could be happening, but I'm not sure how to remedy it.
Comment