Announcement

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

  • Need help combining my race variables into one categorical variable

    Hi,
    I am new to stata and need help with the above complaints.

    I have data that has a variable for Race_1 categorized into "1 = American Indian or Alaskan Native (AI), 2 =Asian, 3=Black or African American, 4=Multi, 5=Others (O) and 6=White. I have another variable, Ethnicity_1, categorized into 0=Not Hispanic (NH) and 1= Hispanic or Latino.

    I want to create a variable race_ethnicity into the following categories 1=NHAI, 2=NHAsian, 3=NHblack, 4=NHmulti, 5=NHOthers, 6=NHwhite and 7=Hispanic or Latino.

    I used egen race_ethnicity =group (Race_1 Ethnicity_1), label
    tab race_ethnicity

    I don't know how to proceed and am unsure if it's the correct code.

    Please help out!


  • #2
    Perhaps this does what you seek.
    Code:
    generate race_ethnicity = Race_1
    replace race_ethnicity = 7 if Ethnicity_1==1

    Comment


    • #3
      Hi William Lisowski,
      Thank you so much!
      It worked!

      Comment


      • #4
        Hi
        I need help on how to merge 2 variables from different data sets.
        I have a data set that contains a variable early_syphilis_count, and I want to merge this into my main data set to a variable Dx.
        Thank you!

        Comment


        • #5
          Your question really isn't clear without more detail, or at a minimum it is too difficult to guess at a good answer from what you have shared. Please help us help you. Show example data. Show your code. Show us what Stata told you. Tell us what precisely is wrong. The Statalist FAQ provides advice on effectively posing your questions, posting data, and sharing Stata output. It is particularly helpful to copy commands and output from your Stata Results window and paste them into your Statalist post using code delimiters [CODE] and [/CODE], and to use the dataex command to provide sample data, as described in section 12 of the FAQ.

          The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

          Added in edit: Your question has nothing to do with the title of this topic. You would gather more attention by starting a new topic and using a more descriptive title when you provide the improved presentation of your question as I suggested.
          Last edited by William Lisowski; 03 Oct 2022, 17:25.

          Comment


          • #6
            Thank you! I will update as advised

            Comment

            Working...
            X