Announcement

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

  • Using -asdoc- to get summary statistics and weights

    Hi Everyone,

    I am using the 2015-16 wave of the Demographic and health survey from India, it contains data on reproductive behaviour and contraception. I have produced summary statistics using asdoc by Attaullah Shah, however I wanted to get summary statistics that would show proportions of a category variable. For example if I wanted to get the summary statistics of say proportion of people belonging to a certain category, where the category could be as follows:

    Code:
     label list `:value label occupation '
    V717:
               0 not in work force/no occupation
               1 professional/technical/managerial
               2 clerical
               3 sales
               5 agricultural
               7 services/household and domestic
               8 manual - skilled and unskilled
              98 don't know
    
    label list `:value label state'
    1 Andhra Pradesh
    2 Assam 
    3 Bihar 
    .
    .
    I want to be able to run asdoc to get the proportion of people belonging to each category to be a part of my summary statistics since in this scenario having the mean of a categorical variable in a survey of individuals does not make much sense.

    Also, does asdoc incorporate weights while generating tables, I have not found any material alluding to that.

    Thanks in advance.

    Lori

  • #2
    Please use dataex (from SSC) and post an example dataset here. Seems to me you may want to use the tabulate command with asdoc.
    see
    Code:
    help asdoc
    and browse to the Section 5 of the help file.
    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

    Comment


    • #3
      Hi Dr. Shah,

      I do not need to tabulate the data instead I wanted to include percentage of each category in my summary statistics.

      For example for occupation in the summary stats I want a breakdown of what percentage of the respondents belong to each category.

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input byte occupation
       .
      
       .
       .
       0
       8
       .
       0
       0
       0
       0
       0
       .
       0
       .
      98
       0
       .
       .
       .
       .
       2
       1
       0
       .
      
       
      end
      label values occupation V717
      label def V717 0 "not in work force/no occupation", modify
      label def V717 1 "professional/technical/managerial", modify
      label def V717 2 "clerical", modify
      label def V717 8 "manual - skilled and unskilled", modify
      label def V717 98 "don't know", modify
      I have attached an example from a published paper. Thank you so much.

      Lori
      Click image for larger version

Name:	Summary_stats.png
Views:	1
Size:	187.4 KB
ID:	1524763

      Comment


      • #4
        The dataset you have posted is not usable as it is truncated. The picture you have posted for the desired table shows that the percentage variable is actually a mean of something. Therefore, you can get it by using the stat() option of asdoc. see this example

        Code:
        webuse grunfeld
        asdoc sum kstock mvalue, stat(N mean sd median)
        ​​​​​​​
        Regards
        --------------------------------------------------
        Attaullah Shah, PhD.
        Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
        FinTechProfessor.com
        https://asdocx.com
        Check out my asdoc program, which sends outputs to MS Word.
        For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

        Comment


        • #5
          Thank you for your guidance Prof. Shah.

          But when I run the asdoc sum command, I get the following output:

          Code:
          asdoc by year: sum age religion educ_single educ_lvl educ_att  tot_child_born currently_preg wanted_currpreg abort_ever contra_current contra_currenttype use_pattern child_wantlast ///
          marital_status_current marital_status unmet_need part_educ_year part_occgroup emp_home reading_freq hh_radio hh_tele radio_use tv_use fp_radio fp_tv, stat(mean median sd N) replace label dec(2)
          2005 - NFHS III
          Variable N Mean Sd Min Max
          Respondent's current age 7947 28.817 9.487 15 49
          Religion 7947 1.502 3.498 1 99
          Education in single years 7947 5.499 5.289 0 99
          Highest educational level 7947 1.21 1.027 0 9
          Educational attainment 7947 1.897 1.682 0 9
          Total children ever born 7947 2.244 2.14 0 12
          Currently pregnant 7947 0.046 0.21 0 1
          Current pregnancy wanted 368 1.446 0.674 1 3
          Ever had a terminated pregnancy 7947 0.153 0.372 0 9
          Current contraceptive method 7947 2.556 3.188 0 18
          Current use by method type 7947 1.258 1.437 0 3
          Pattern of use 7947 2.532 1.432 1 4
          Wanted last child 2403 1.438 0.746 1 9
          Current marital status (see s301 7947 0.871 0.706 0 5
          Currently/formerly/never in unio 7947 0.81 0.484 0 2
          Unmet need 7947 3.947 5.447 0 99
          Husband/partner's highest year o 6155 4.251 10.585 0 99
          Husband/partner's occupation (gr 6155 5.799 6.657 0 99
          Respondent works for family, oth 2852 1.704 0.735 1 3
          Frequency of reading newspaper o 7947 0.793 1.125 0 9
          Household has: radio 7947 0.676 1.519 0 9
          Household has: television 7947 0.918 1.458 0 7
          Frequency of listening to radio 7947 0.936 1.188 0 9
          Frequency of watching television 7947 1.865 1.287 0 9
          Heard family planning on radio l 7947 0.334 0.518 0 9
          Heard family planning on tv last 7947 0.573 0.53 0 9

          As you can see, the categorical variables do not make sense or convey any information. Would it be more sensible if I were to use categorical variables like religion or household has radio , then should I manually tab the variable with year and then fill out the table. Is there a way to get this output in another way?

          Best,

          Lori

          Comment


          • #6
            Since I wanted the percentage of people belonging to each category in a categorical variable, I was able to generate the table below. However, I had to manually tab out the categorical variable and then insert them into the table after running asdoc sum. Is there an easier way to do this?

            Descriptive Statistics
            year of interview: 1992
            Variable Mean (/%) Median sd N
            respondent's current age 30.64 30 8.93 37142
            religion 2.38 1 10.65 36988
            Hindu (%) 84.97 . . 31,427
            Muslim (%) 10.47 . . 3,871
            Christian (%) 3.29 . . 1,218
            Other (%) 1.28 . . 472
            education in single years 3.37 0 6.51 37142
            highest educational level 0.71 0 . 37142
            no education (%) 57.9 . . 21,504
            primary (%) 18.93 . . 7,030
            secondary (%) 19.46 . . 7,227
            higher (%) 3.46 . . 1,285
            total children ever born 3.02 3 2.24 37142
            currently pregnant 0.08 0 . 37142
            no or unsure (%) 92.17 . . 34,232
            yes (%) 7.83
            . . 2,910
            household has: radio 0.46 37142
            no (%) 54.71 20,319
            yes (%) 45.2 16,787
            household has: television 0.24 37142
            no (%) 77.01 28,604
            yes (%) 22.91 8,508
            heard family planning on radio l 0.38 37142
            no (%) 62.64 23,264
            yes (%) 37.34 13,867
            heard family planning on tv last 0.3 37142
            no (%) 70.76 26,280
            yes (%) 29.19 10,840
            Thanks a lot!

            Lori
            Last edited by Lorien Nair; 19 Nov 2019, 03:28.

            Comment


            • #7
              It is hard to figure out a solution here without seeing the actual data and the way you are calculating the percentage. As suggested in #2, post a data example that can be used on Stata and the code that you are using for finding the percentages.
              Regards
              --------------------------------------------------
              Attaullah Shah, PhD.
              Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
              FinTechProfessor.com
              https://asdocx.com
              Check out my asdoc program, which sends outputs to MS Word.
              For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

              Comment


              • #8
                Dear Prof. Shah,

                I use the -tab- command to get percentages since they are categorical variables, so:

                Code:
                tab religion if year == 1992
                Code:
                dataex age religion educ_lvl currently_preg
                Code:
                * Example generated by -dataex-. To install: ssc install dataex
                
                clear
                input byte age float religion byte(educ_lvl currently_preg)
                46 3 0 0
                20 3 3 0
                40 1 1 0
                21 1 3 0
                19 1 3 0
                26 1 2 0
                43 1 2 0
                17 1 2 0
                22 1 2 0
                35 1 2 0
                25 1 3 0
                46 3 2 0
                17 2 2 0
                40 3 2 0
                21 3 2 0
                17 3 2 0
                46 1 3 0
                40 1 2 0
                37 1 2 0
                37 1 2 0
                33 3 2 0
                44 1 2 0
                24 1 3 0
                21 1 3 0
                42 1 3 0
                35 1 3 0
                27 1 3 0
                34 2 3 0
                20 3 2 0
                24 3 2 0
                40 3 1 0
                33 3 2 0
                32 3 2 0
                47 3 1 0
                19 3 2 0
                48 3 2 0
                24 3 2 0
                32 3 2 0
                20 3 2 0
                30 3 2 0
                38 3 2 0
                31 3 2 0
                40 3 2 0
                22 3 2 0
                43 3 2 0
                23 3 2 0
                17 3 2 0
                20 3 2 0
                45 3 1 0
                15 3 2 0
                31 3 2 0
                46 3 0 0
                29 3 2 0
                41 3 2 0
                40 3 2 0
                18 3 0 0
                16 3 2 0
                27 3 2 0
                16 3 2 0
                30 3 0 0
                40 3 1 0
                28 3 2 0
                38 3 1 0
                44 3 0 0
                32 3 2 0
                43 2 2 0
                17 2 2 0
                49 3 2 0
                31 3 2 0
                42 3 1 0
                46 3 2 0
                29 3 2 0
                37 3 2 0
                36 3 2 0
                48 3 2 0
                22 3 2 0
                49 3 2 0
                40 3 2 0
                29 3 2 0
                32 3 2 0
                48 3 1 0
                18 3 2 0
                29 3 2 0
                25 3 2 0
                43 3 2 0
                17 3 2 0
                15 3 2 0
                37 3 2 0
                41 3 3 0
                39 3 1 0
                39 3 1 0
                46 3 2 0
                43 3 0 0
                39 3 2 0
                39 3 2 0
                39 3 2 0
                19 3 2 0
                45 3 2 0
                22 3 2 0
                36 3 2 0
                end
                label values religion V130
                label def V130 1 "hindu", modify
                label def V130 2 "muslim", modify
                label def V130 3 "christian", modify
                label values educ_lvl V106
                label def V106 0 "no education", modify
                label def V106 1 "primary", modify
                label def V106 2 "secondary", modify
                label def V106 3 "higher", modify
                label values currently_preg V213
                label def V213 0 "no or unsure", modify
                ​​​​​​​

                Comment

                Working...
                X