You are not logged in. You can browse but not post. Login or Register by clicking 'Login or Register' at the top-right of this page. For more information on Statalist, see the FAQ.
How can I append a file containing an encoded variable? While appending the files, the encoded (long format) variable`s observations are changing. How to fix it.
You can append easily enough, but the problem is evidently that different encodes have produced inconsistent mappings. There isn't a solution I know other than reversing the encode, appending datasets with string variables, and then applying encode to the union.
The problem arises because some previous user(s) didn't think hard enough about the consequences of what they were doing, and this is easy (not) to do, and many of us have been bitten by it, despite advice from experienced users such as that at https://www.stata-journal.com/articl...article=dm0057
That is, a user relying on the default of encode would find that distinct values "a" "b" "d" would get mapped to 1 2 3 in one dataset; while distinct values "a" "b" "e" would get mapped to 1 2 3 in another. The problems I've seen are typically variations on that.
Worse, variations in spelling and punctuation that are trivial to any user will get taken very literally by encode unless you specify value label mappings in advance.
Comment