1606071216 Destring-ing data with entry errors or coding problems
The "ds" command already mentioned is a powerful tool to clean up and analyse rebellious data. Say you know that your data is numerical but for some reason has been stored as string, you can:
- spend time identifying by hand the string variables and destring them all at once or one by one
- execute this:
ds _all, has(type string)
local tolist
foreach var of local tolist {
di "
var'" `
count if real(
var')==.`
if r(N)!=0 list
var' if real(var')==.
}
This allows you to ex-ante check whether your supposed numerical variables take non-numerical values, and props them in a list. You can then work on them, and ultimately destring the variables needed.