Hello,
I have a dataset with ~881k observations and 621 variables that I'm just beginning to clean.
The vast majority of the data is numeric but I have a chunk of 87 variables that are stored as string and contain either "yes", "no" or ".". I can encode them in a loop using the below but this also encodes "." as a number.
I have read the help files on encode and searched several posts and articles but I'm beginning to think it either isn't possible and I need to approach it another way or i'm missing something plainly obvious that I just cannot see?
foreach v of varlist var1-var87{
encode `v', generate (new`v')
drop `v'
rename new`v' `v'
}
Any advice would be appreciated.
I'm using STATA 16 SE
Aidan
Related Posts with Loop Encode but ignore "."
Multi Level Modelling with clustered standard errorsHello, I have an unbalanced dataset of 6381 firm observations, from 23 countries and 152 industries…
Tab two string variablesHi everyone, This might be an easy question, but I just can't get to the right command. I have two…
Keyword-in-context analysisDear Statalist, I am trying to extract the five words before and after a given keyword in a string …
Stata 16.1MP memory issuesI am running the examples provided by -spgrid- command on my Stata 16.1 MP 2-core and Windows 10: …
Crosstabulation with too many valuesDear all, I would like to see the significance of cross tabulation of two variables, however, if I…
Subscribe to:
Post Comments (Atom)
0 Response to Loop Encode but ignore "."
Post a Comment