Announcement

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

  • Percentage by group in Stata

    Dear all,
    I have the following problem: I want to compute the percentage of people providing unpaid care across the 28 waves of data that I have.
    To do so I have used the following code:

    table wave, statistic (mean dcare care_changes_in care_changes_out care_changes)

    1) Am I right to believe that being dcare a dummy variable that takes value one if the individual provides care and zero otherwise, the mean would give me the percentage of people providing care?

    2) I want to split the percentage computed in step 1 across women and men in my sample.
    If I use:

    table (wave) (gender dcare), nototals statistic(percent, across(dcare))

    (where gender takes value 0 for women and 1 for men)
    it seems to me that I am computing the proportion of women among the subsample of women and the proportion of men among the subsample of men that provide care in that certain wave.
    However ideally I would want to know of the overall percentage (computed in step 1) how much of it is to be attributed to men and how much to women. Does it make any sense?

    Ideally I would love to avoid computing each single percentage because I will need to do this work also across nations, regions, age group, and social class.
    Thank you so much for your help and your time.

  • #2
    Maria:
    without taking a look at what Stata gave you back (as per FAQ9 it is difficult to reply positively.
    That said:
    1) correct;
    2) what if you try:
    Code:
    table (wave gender dcare), nototals statistic(percent, across(dcare))
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Dear Carlo,
      thank you so much for your quick and kind reply.
      I just read the FAQ and I know now how to show you the kind of data I have but I do not really know how to show my output.
      If it can be of any use those are the data I have:

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input long pidp float(wave gender dcare)
       1367  1 1 0
       1367  2 1 0
       2051  1 1 0
       2051  2 1 0
       2727  2 0 0
       2727  8 0 0
       2727  9 0 0
       2727 10 0 0
       2727 11 0 0
       3407  1 1 0
       3407  2 1 0
       3407  4 1 0
       3407  9 1 0
       4091  1 1 0
       4091  2 1 0
       4091  3 1 0
       4091  4 1 0
       4767  1 1 1
       4767  2 1 0
       4767  3 1 1
       5451  1 0 0
       5451  2 0 0
       5451  3 0 1
       6135  1 1 0
       6135  2 1 0
       6135  3 1 1
       6807  2 1 0
       6807  3 1 0
       6882  7 1 0
       6882  8 1 0
       7487  1 1 0
       7487  2 1 0
       7487  4 1 0
       7487  5 1 0
       8167  4 1 0
       8167  5 1 0
       9527  1 0 0
       9527  2 0 0
       9527  3 0 0
       9527  4 0 0
       9527  5 0 0
       9527  6 0 0
       9527  7 0 0
       9527  8 0 0
       9527  9 0 0
       9527 10 0 0
       9527 11 0 0
      12251  1 0 0
      12251  2 0 0
      12251  3 0 0
      12251  4 0 0
      12251  5 0 0
      12251  6 0 0
      12251  7 0 0
      12251  8 0 0
      12251 10 0 0
      12251 12 0 0
      12251 13 0 0
      12251 14 0 0
      12935  1 0 0
      12935  2 0 0
      12935  3 0 0
      12935  5 0 0
      12935  6 0 0
      12935  7 0 0
      12935  8 0 0
      14287  1 1 0
      14287  2 1 0
      14287  3 1 0
      14287  4 1 0
      14287  5 1 0
      14287  6 1 0
      14287  9 1 0
      14971  1 0 0
      14971  2 0 0
      14971  3 0 0
      14971  4 0 0
      14971  5 0 0
      14971  6 0 0
      14971  9 0 1
      14971 10 0 0
      14971 11 0 0
      14971 12 0 0
      14971 13 0 0
      14971 14 0 0
      15645  1 0 1
      15645  2 0 0
      15645  3 0 1
      15645  4 0 1
      15645  5 0 0
      15645  6 0 0
      15645  7 0 0
      15645  8 0 1
      15645  9 0 1
      15645 10 0 1
      15645 11 0 0
      15645 12 0 1
      15645 13 0 1
      15645 14 0 0
      15645 15 0 0
      end
      label values gender gender
      label def gender 0 "Female", modify
      label def gender 1 "Male", modify
      label values dcare dcare
      label def dcare 0 "No", modify
      label def dcare 1 "Yes", modify
      Using
      Code:
      table  wave, statistic (mean dcare )

      gives me that in wave 1, the percentage of people who provides care is 0.1694 (16.94%).
      I just want to understand how much of this percentage is composed by men and how much by women.

      If I use your code (that works similarly to mine) I get that in wave 1, 80.12 percent of women do not provide care versus the 19.88 percent of women who do provide care. On the other hand I get that 86.25% of men do not provide care versus the 13.75 of men who do provide care. This, however, tells me nothing on the composition of this 16.94% that I find in the first step.

      Could it be that the following code:

      Code:
      table (wave) ( dcare gender) if dcare==1 , nototals statistic(percent, across(gender))
      is instead the one I am looking for?

      Thank you so much for your help


      Comment


      • #4
        Maria:
        do you mean something along the following lines?
        Code:
        .  table wave gender if dcare==1, statistic (percent dcare, across(gender))
        
        ----------------------------------
                |           gender        
                |  Female    Male    Total
        --------+-------------------------
        wave    |                         
          1     |   50.00   50.00   100.00
          3     |   50.00   50.00   100.00
          4     |  100.00           100.00
          8     |  100.00           100.00
          9     |  100.00           100.00
          10    |  100.00           100.00
          12    |  100.00           100.00
          13    |  100.00           100.00
          Total |   76.92   23.08   100.00
        ----------------------------------
        
        .
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Thank you so much for this Carlo.

          With
          Code:
           table  wave , statistic (mean dcare)
          I get that:

          -------------------
          | Mean
          --------+----------
          wave |
          1 | .1694935
          2 | .1614862
          3 | .1773575
          4 | .1711769
          5 | .1700895
          6 | .1577944
          7 | .1727754
          8 | .1656285
          9 | .1890571
          10 | .198721
          11 | .2036003
          12 | .2018032
          13 | .1956823
          14 | .2017783
          15 | .1913887
          16 | .195273
          17 | .2153885
          18 | .1928384
          19 | .2067596
          20 | .223108
          21 | .2117268
          22 | .2138854
          23 | .2325797
          24 | .1940629
          25 | .2003341
          26 | .2010648
          27 | .1970355
          28 | .189889
          Total | .200753

          When I use the code suggested from you
          Code:
          table wave gender if dcare==1, statistic (percent dcare, across(gender))
          I get the following:


          ----------------------------------
          | Gender
          | Female Male Total
          --------+-------------------------
          wave |
          1 | 61.21 38.79 100.00
          2 | 61.20 38.80 100.00
          3 | 61.53 38.47 100.00
          4 | 60.85 39.15 100.00
          5 | 59.67 40.33 100.00
          6 | 59.98 40.02 100.00
          7 | 59.64 40.36 100.00
          8 | 59.44 40.56 100.00
          9 | 60.51 39.49 100.00
          10 | 60.99 39.01 100.00
          11 | 60.60 39.40 100.00
          12 | 58.79 41.21 100.00
          13 | 59.73 40.27 100.00
          14 | 60.02 39.98 100.00
          15 | 60.87 39.13 100.00
          16 | 60.18 39.82 100.00
          17 | 59.89 40.11 100.00
          18 | 61.46 38.54 100.00
          19 | 61.91 38.09 100.00
          20 | 61.44 38.56 100.00
          21 | 61.91 38.09 100.00
          22 | 60.75 39.25 100.00
          23 | 60.93 39.07 100.00
          24 | 62.13 37.87 100.00
          25 | 61.47 38.53 100.00
          26 | 62.33 37.67 100.00
          27 | 61.48 38.52 100.00
          28 | 62.04 37.96 100.00
          Total | 61.18 38.82 100.00
          ----------------------------------

          1) Am I right to say that of those 16.9 percent of individuals that provide unpaid care, 61.21 percent are female and 38.79 are male?

          2)What ideally I would want is a table that lists for each wave the percentage of those providing unpaid care, and among those a clear comparison between women and men. Is there any way to decompose 16.9 directly so that the sum of the proportion of men and women will be exactly 16.9 ?(hence, the percentage of female is computed over the overall sample - and not only in relation to the female subsample. And the same for the male subsample).

          Thank you so much for your time and your precious advices.

          Last edited by Maria Petrillo; 18 Jul 2022, 02:24.

          Comment


          • #6
            Maria:
            do you mean something along the following lines?
            Code:
            . table wave dcare gender , statistic(percent, across( dcare ))
            
            ---------------------------------------
                        |           gender         
                        |  Female     Male    Total
            ------------+--------------------------
            wave        |                          
              1         |                          
                dcare   |                          
                  No    |   83.33    87.50    85.71
                  Yes   |   16.67    12.50    14.29
                  Total |  100.00   100.00   100.00
              2         |                          
                dcare   |                          
                  No    |  100.00   100.00   100.00
                  Total |  100.00   100.00   100.00
              3         |                          
                dcare   |                          
                  No    |   66.67    60.00    63.64
                  Yes   |   33.33    40.00    36.36
                  Total |  100.00   100.00   100.00
              4         |                          
                dcare   |                          
                  No    |   75.00   100.00    88.89
                  Yes   |   25.00             11.11
                  Total |  100.00   100.00   100.00
              5         |                          
                dcare   |                          
                  No    |  100.00   100.00   100.00
                  Total |  100.00   100.00   100.00
              6         |                          
                dcare   |                          
                  No    |  100.00   100.00   100.00
                  Total |  100.00   100.00   100.00
              7         |                          
                dcare   |                          
                  No    |  100.00   100.00   100.00
                  Total |  100.00   100.00   100.00
              8         |                          
                dcare   |                          
                  No    |   80.00   100.00    83.33
                  Yes   |   20.00             16.67
                  Total |  100.00   100.00   100.00
              9         |                          
                dcare   |                          
                  No    |   50.00   100.00    66.67
                  Yes   |   50.00             33.33
                  Total |  100.00   100.00   100.00
              10        |                          
                dcare   |                          
                  No    |   80.00             80.00
                  Yes   |   20.00             20.00
                  Total |  100.00            100.00
              11        |                          
                dcare   |                          
                  No    |  100.00            100.00
                  Total |  100.00            100.00
              12        |                          
                dcare   |                          
                  No    |   66.67             66.67
                  Yes   |   33.33             33.33
                  Total |  100.00            100.00
              13        |                          
                dcare   |                          
                  No    |   66.67             66.67
                  Yes   |   33.33             33.33
                  Total |  100.00            100.00
              14        |                          
                dcare   |                          
                  No    |  100.00            100.00
                  Total |  100.00            100.00
              15        |                          
                dcare   |                          
                  No    |  100.00            100.00
                  Total |  100.00            100.00
              Total     |                          
                dcare   |                          
                  No    |   84.62    91.43    87.00
                  Yes   |   15.38     8.57    13.00
                  Total |  100.00   100.00   100.00
            ---------------------------------------
            
            .
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment

            Working...
            X