Announcement

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

  • How to calculate percents in STATA

    I am a novice at using Stata, so please forgive my question. I need to find an immediate command to use to just calculate some percentages, and I am not sure how to do that. I have a two way table, but it contains 3 groups, not just 2, as in the following:

    Treatment Outcome
    Recurring symptoms No recurring symptoms Total
    Drug1 4 29 33
    Drug2 14 19 33
    Control 17 17 34

    I want to find the percentages of using the Treatment (Drug1, Drug2, and the Control) that are having No Recurring symptoms in each of the three treatment groups.

    Thanks very much.
    Last edited by Karen Allen; 11 Oct 2017, 19:37.

  • #2
    Code:
    display 100*29/33, 100*19/33, 100*17/34

    Comment


    • #3
      Clyde gave you an excellent shortcut to get the percentages. Hence, problem solved.

      That said, I hope you won't take it amiss, but your question conveys the feeling that the main issue, far from being the calculation of percentages, might well be the (lack of) preparation of the data set.

      Being this so, little wonder you cannot "easily" estimate percentages for your data in Stata.

      Furthermore, I assume you will need to "proceed" with some estimation, whichever it may be, beyond "crude" percentages.

      To show you an example, I tried to keep the same information you shared, but keep in mind that "total" as well as both variables "symptoms" and "no symptoms" are unnecessary.

      Below, you have 3 kinds of percentages (row wise column wise and percentages of the total).

      Code:
      . input drug symptoms freq
      
                drug   symptoms       freq
        1. 1 1 4
        2. 1 0 29
        3. 2 1 14
        4. 2 0 19
        5. 3 1 17
        6. 3 0 17
        7. end
      
      . label define drug 1 "Drug1" 2 "Drug2" 3 "Control"
      
      . label values drug drug
      
      . label define symptoms 0 "No" 1 "Yes"
      
      . label values symptoms symptoms
      
      . expand freq
      (94 observations created)
      
      . tabulate drug symptoms, cell column row
      
      +-------------------+
      | Key               |
      |-------------------|
      |     frequency     |
      |  row percentage   |
      | column percentage |
      |  cell percentage  |
      +-------------------+
      
                 |       symptoms
            drug |        No        Yes |     Total
      -----------+----------------------+----------
           Drug1 |        29          4 |        33
                 |     87.88      12.12 |    100.00
                 |     44.62      11.43 |     33.00
                 |     29.00       4.00 |     33.00
      -----------+----------------------+----------
           Drug2 |        19         14 |        33
                 |     57.58      42.42 |    100.00
                 |     29.23      40.00 |     33.00
                 |     19.00      14.00 |     33.00
      -----------+----------------------+----------
         Control |        17         17 |        34
                 |     50.00      50.00 |    100.00
                 |     26.15      48.57 |     34.00
                 |     17.00      17.00 |     34.00
      -----------+----------------------+----------
           Total |        65         35 |       100
                 |     65.00      35.00 |    100.00
                 |    100.00     100.00 |    100.00
                 |     65.00      35.00 |    100.00
      Hopefully that helps.
      Last edited by Marcos Almeida; 11 Oct 2017, 20:27.
      Best regards,

      Marcos

      Comment

      Working...
      X