I am encoding a list of categorical variables that are common in four datafiles, one file per city. In each city the items of the list are not always the exact same, but there are certain items such as "refused" that recur. So there is partial intersection if we think in terms of Venn diagrams.
Sencode is great at encoding and also creating a label that I can then apply to the same var in the next city, so that common values get the same value label. My problem is that I want to "reserve" /define some particular values myself. Specifically, -3 "refused", -2 "do not know," -1 "missing", and the most important one, 9 "other(specify)". The 9 is the problematic value because for whatever reason, once I add it to the label, sencode then skips all digits below 9 when adding to that label. This is contradictory to the manual from what I can tell, which says it goes from 1 to x without exception. By example I have a sex variable, and due to this problem it ends up encoded as 9 Other(specify), 10 Female and 11 Male. I want sencode to start from 1 Female, and so on.
Of course I can make other(Specify) -4 and this solves the problem, but it would be much neater if the 9 was kept as this matches the questionnaire. I have thought up a few ugly solutions to this, but it feels like there should be something simpler. What am I missing and what can I try?
Code:
foreach var of local encode_list { label define `var'_label -3 "Refused" -2 "Do not know" -3 "Missing" 9 "Other (Specify)" sencode `var', label(`var'_label) replace }
0 Response to Encode or sencode with specific reserved value labels
Post a Comment