Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Recoding Racial Groups; Latino =2, but I want Latino =1, etc.

    My current dataset has racial groups coded as: White = 0, Black = 1, Latino = 2, Multi-Racial = 3, Filipino = 4.
    However, I would like White = 0, Latino = 1, Black = 2, Asian = 3, Multi-Racial = 4.
    How do I reorder these codes to match the correct racial group, and how do I tell Stata to make Filipino = Asian.

    I've spent several hours looking at recode, rename, gen, and I'm lost. Your help is greatly appreciated.

    Thank you,

  • #2
    Assuming your variable is called var1 and it's label is called lab1.


    Code:
    recode var1 (0=0) (1=2) (2=1) (3=4) (4=3) //OR generate a new variable first and then recode that var to check recoding
    lab def lab 0 "White 1 "Latino" 2 "Black"   3  "Asian" 4 "Multi-Racial", modify
    lab val var1 lab1 //not really needed, but jic.
    Eric A. Booth | Senior Director of Research | Far Harbor | Austin TX

    Comment


    • #3
      Thanks for your help. Unfortunately, when I try this, Stata changes the data, so if the Black n = 9, and Latino n = 1, after recoding, it will show Latino n = 9 and Black n =1. How do I tell Stata to keep the data in each code, but recode the variables?

      Comment


      • #4
        So what you really want to do is just change the labeling of the variable. It seems a bit odd because calling Black Latino and vice versa sounds like a really material change. Is this because the original labeling arose through some kind of mistake that you are trying to undo?

        Anyway, assuming you have a good reason to do this, skip the -recode- command that Eric Booth suggested and just do:

        Code:
        lab def lab 0 "White" 1 "Latino" 2 "Black" 3 "Asian" 4 "Multi-Racial", modify
        and the relabeling will be accomplished.

        After seeing #5, I realized that I had not noticed the omission of the closing quote after White either. So I have changed it accordingly.

        Again, it is unclear to me what you want to do here. If all you want to do is change the labeling, this will do it. But in light of #5 it may be that you actually wanted the -recode- and ran into an incorrect tabulation because the -lab def- command did not actually run.
        Last edited by Clyde Schechter; 22 May 2018, 18:53.

        Comment


        • #5
          Eric forgot to type the double quotes after White. Perhaps you didn't notice the "invalid syntax" message and ended up with your original label instead of the modified one.

          Comment


          • #6
            I need to merge two dataset, and they have different coding mechanism. I got it to work. Thanks for everyone's support.

            Comment

            Working...
            X