Announcement

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

  • Combining dichotomous variables

    Hello,
    I have a large dataset which is already programmed into STATA of which I want to combine 8 variables for a descriptive table analysis.
    They are all dichotomous 'yes/no' variables, and are involved in history of medical conditions. There were 8 questions for participants for which they answered yes/no for the 8 conditions and therefore I have 8 variables. I want to present the data in a descriptive table as 'Participants with history of any of the following [8 conditions]' and state n (%).
    for example:
    heart disease Rheumatoid Arthritis High blood pressure
    1 yes no no
    2 no no yes
    3 no no no
    4 yes no yes
    which would show 'Participants with any history of heart disease, RA or high BP' which would be 3 (75%).

    I am new to STATA so apologise if this is a very basic question!

    Thanks

  • #2
    my guess (please read the FAQ for advice on how to ask questions) is that the user-written -mrtab- will do what you want; use -search- to find and download

    Comment


    • #3
      Thank you very much for your help - I downloaded the -mrtab- function and I could obtain my answer by the number of 'Valid cases'. I have also read the FAQ advice and I apologise for my errors in asking the question.

      Comment


      • #4
        See also tabm from tab_chi on SSC.

        Pedantic footnote: mrtab is a command, not a function.

        Comment


        • #5

          Nick - thank you for your response, I tried tabm also. It was very useful for showing frequencies of individual variables together in a table, however I am after the number of individuals that have answered a specific answer at least once across several variables (I hope I am making sense).

          I was utilising the mrtab command whilst my variables were dichotomous, as mrtab defaults to show the frequency of cases with the value of 1. For example (I have anonymised my data):
          Frequency Percent of responses Percent of cases
          drug_use_20y 141 43.25 62.39
          drug_use_22y 164 50.31 72.57
          drug_use_24y 20 6.13 8.85
          drug_use_26y 1 0.31 0.44
          Total 326 100.00 144.25
          Valid cases: 226
          Missing cases: 271

          With the answers to the four variables above being 1=yes and 0=no (to drug use at the respective ages)
          Therefore 226 of the study participants reported drug use at least once at the age 20, 22, 24 or 26.

          I now have a variable x that has 5 outcomes (1-5), of which both 4 and 5 class as 'yes' for drug use, for example 4 = occasional drug use and 5 = regular drug use. I have changed the mrtab table as to show the frequency of individuals that answered 4 or 5 by using mrtab variable x, response(4, 5)

          I want to be able to create a mrtab table using 4 variables again, but this time with two outcomes per variable, such as:
          mrtab variable x, response(4,5) variable y, response(2) variable z, response(3)
          Obviously the above command is invalid as
          invalid 'response'
          r(198);

          is the result. I have tried adding brackets round individual elements and have read "Jann, B. (2005). Tabulation of multiple responses. The Stata Journal, 5(1), 92-122." but still can't figure out how to correctly type the command/ if the mrtab command is the correct one I should be using.

          The version of STATA I am using: Stata/IC 16.1 for Mac (as the dataset is transferred over VPN and this is the version I have been told is compatible with the dataset).

          Comment


          • #6
            mrtab is an excellent command in Stata (not STATA please) which I have hardly ever used. But as you are realising, your syntax is fantasy syntax a long way from anything legal and also supported by that command.

            It's just possible that some syntax like

            mrtab x y z if inlist(x, 4, 5) | y == 2 | z == 5

            gets you some of the way.

            These variables aren't dichotomous!

            You may be better off with a long layout for these data which look like panel data in disguise!

            Comment

            Working...
            X