Announcement

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

  • How to combine or tabulate same values labels from different variables?

    I have searched wide and far, but can't seem to find a problem matching mine. How do I combine values from different variables that have the same value labels?
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long Diagnosis1 byte(hp1_f_notype hp2_f_notype hp3_f_notype)
    1  . . .
    2  2 1 3
    1  5 . .
    2  5 . .
    2  5 . .
    1  5 . .
    1  3 2 5
    1 99 . .
    1  2 . .
    1  5 . .
    end
    label values Diagnosis1 Diagnosis1
    label def Diagnosis1 1 "IIH", modify
    label def Diagnosis1 2 "none-IIH", modify
    label values hp1_f_notype Phenotype
    label values hp2_f_notype Phenotype
    label values hp3_f_notype Phenotype
    label def Phenotype 2 "Migraine with aura", modify
    label def Phenotype 3 "Tension headache", modify
    label def Phenotype 5 "Other", modify
    label def Phenotype 99 "Don't know", modify
    label def Phenotype 1 "Migraine without aura", modify
    Click image for larger version

Name:	Variables.PNG
Views:	1
Size:	17.8 KB
ID:	1639846
    I essentially just want to combine these value labels in one row with all the phenotypes.

  • #2
    tabm from tab_chi on SSC may help. See e;g; https://www.statalist.org/forums/for...isions-to-tabm

    Comment


    • #3
      Thanks for the reply. I've tried tabm before, but I'm not sure how to combine it or code it, so that it shows the Headache phenotypes associated with the IIH and none-IIH like the picture shown above.

      Comment


      • #4
        You're correct. It won't do that.

        Comment


        • #5
          Do you know a command which would help me do that?

          Comment


          • #6
            See help table

            (As you haven't declared otherwise, I am assuming that you are using Stata 17.)

            Comment


            • #7
              Yes, I'm using Stata 17, and I've tried reading through "help table", but I can't seem to figure out how to do it. I'm fairly new to Stata.

              Comment


              • #8
                Sorry, no free lunch here.

                If you want a table just once, then it might be easiest to do the calculations in Stata and use your favourite word or text processing software to build the table using what you already know about that software.

                If you want a customised table to repeat a hundred times with different data, the bad news may be that the code may take several hours or days to get right but that might be a reasonable expenditure of effort.

                Comment


                • #9
                  Okay, thanks for the help nonetheless.

                  Comment

                  Working...
                  X