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.
Hello! I additionally need some help. I've used the egen and group function to create a race_ethnicity variable from individual race variable responses. My code is:
and it returns what is in the attached screenshot. The frequencies from NH White through NH American Indian/Alaska Native are correct. On the next line for NH Native Hawaiian it says the frequency is 11, but that is actually the frequency for the above race response (NH Unknown) and the frequency for NH Native Hawaiian is actually 0. So essentially it is shifting all the numbers down. Is there a way I can adjust my code (or create a completely new code) so that NH Native Hawaiian (or any other race for that matter) doesn't show up if the frequency is 0?
The problem arises because -egen, group()- cannot anticipate how you will define your label. Finding no observations where nhnh = 1, it does not reserve any numerical value for this unattested category of NH Native Hawaiian. Instead, it continues assigning consecutive numerical values to the combinations it encounters. Consequently, the label you define is out of sync with what -egen- did. So, remove NH Native Hawaiian from your label definition, and then renumber the subsequent categories to start from 4 instead of 5, and you should be OK.
Comment