Announcement

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

  • How to create table for descriptive statistics

    Hi, I was wondering what are the command to create a table that gives me this statistics? I mean a table as the one in the picture that provides for each groups the proportion for each profession.
    Click image for larger version

Name:	Immagine 2022-02-05 230818.png
Views:	2
Size:	53.2 KB
ID:	1648839



    my dataset is
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(percent1 percent2 percent3 occupation_name)
    .15052333 . . 6
    .15052333 . . 6
    .07870075 . . 7
    .15052333 . . 6
    .15052333 . . 6
    .15052333 . . 6
    .15052333 . . 6
    .15052333 . . 6
    .07999493 . . 8
    .07870075 . . 7
    .03209662 . . 1
    .15052333 . . 6
    .15052333 . . 6
    .07999493 . . 8
    .15052333 . . 6
    .15052333 . . 6
    .03209662 . . 1
    .15052333 . . 6
    .15052333 . . 6
    .15052333 . . 6
    .03209662 . . 1
    .15052333 . . 6
    .15052333 . . 6
    .15052333 . . 6
    .15052333 . . 6
    .03209662 . . 1
    .15052333 . . 6
    .07999493 . . 8
    .15052333 . . 6
    .07999493 . . 8
    .15052333 . . 6
    .07870075 . . 7
    .03209662 . . 1
    .03209662 . . 1
    .15052333 . . 6
    .12454466 . . 4
    .15052333 . . 6
    .15052333 . . 6
    .15052333 . . 6
    .03209662 . . 1
    .15052333 . . 6
    .07870075 . . 7
    .07999493 . . 8
    .18556127 . . 5
    .15052333 . . 6
    .07999493 . . 8
    .15052333 . . 6
    .15052333 . . 6
    .15052333 . . 6
    .07999493 . . 8
    .07999493 . . 8
    .03209662 . . 1
    .15052333 . . 6
    .15052333 . . 6
    .07999493 . . 8
    .07999493 . . 8
    .12454466 . . 4
    .15052333 . . 6
    .15052333 . . 6
    .07999493 . . 8
    .15052333 . . 6
    .07870075 . . 7
    .03209662 . . 1
    .07870075 . . 7
    .15052333 . . 6
    .07999493 . . 8
    .15052333 . . 6
    .07999493 . . 8
    .18539837 . . 3
    .07999493 . . 8
    .07999493 . . 8
    .07999493 . . 8
    .15052333 . . 6
    .18539837 . . 3
    .15052333 . . 6
    .15052333 . . 6
    .07999493 . . 8
    .15052333 . . 6
    .15052333 . . 6
    .15052333 . . 6
    .15052333 . . 6
    .07999493 . . 8
    .07999493 . . 8
    .15052333 . . 6
    .15052333 . . 6
    .07999493 . . 8
    .15052333 . . 6
    .15052333 . . 6
    .15052333 . . 6
    .03209662 . . 1
    .15052333 . . 6
    .15052333 . . 6
    .15052333 . . 6
    .15052333 . . 6
    .15052333 . . 6
    .15052333 . . 6
    .15052333 . . 6
    .03209662 . . 1
    .07999493 . . 8
    .15052333 . . 6
    .  .3693903 . 8
    .  .3693903 . 8
    .   .184801 . 6
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .   .184801 . 6
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .   .184801 . 6
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .   .184801 . 6
    .  .3693903 . 8
    .   .184801 . 6
    .   .184801 . 6
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .   .184801 . 6
    . .07599492 . 7
    .  .3693903 . 8
    .  .3693903 . 8
    .   .184801 . 6
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .   .184801 . 6
    .   .184801 . 6
    .   .184801 . 6
    .  .0296359 . 3
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .   .184801 . 6
    .  .3693903 . 8
    .   .184801 . 6
    .  .3693903 . 8
    . .07599492 . 7
    .  .3693903 . 8
    .  .3693903 . 8
    .   .184801 . 6
    .   .184801 . 6
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .   .184801 . 6
    .  .3693903 . 8
    .  .3693903 . 8
    .   .184801 . 6
    .  .3693903 . 8
    .   .184801 . 6
    .  .3693903 . 8
    .   .184801 . 6
    .  .3693903 . 8
    .   .184801 . 6
    .   .184801 . 6
    .  .3693903 . 8
    .   .184801 . 6
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .   .184801 . 6
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .   .184801 . 6
    .   .184801 . 6
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    .  .3693903 . 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .22881356 6
    . .  .59322035 8
    . .  .22881356 6
    . .  .59322035 8
    . .  .59322035 8
    . .  .22881356 6
    . .  .59322035 8
    . .  .22881356 6
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .22881356 6
    . .  .59322035 8
    . .  .22881356 6
    . .  .59322035 8
    . .  .22881356 6
    . .  .05084746 7
    . .  .59322035 8
    . .  .05084746 7
    . .  .05084746 7
    . .  .22881356 6
    . .  .22881356 6
    . . .016949153 3
    . .  .59322035 8
    . .  .22881356 6
    . .  .05084746 7
    . .  .22881356 6
    . .  .22881356 6
    . .  .22881356 6
    . .  .59322035 8
    . .  .22881356 6
    . .  .05084746 7
    . .  .22881356 6
    . .  .22881356 6
    . .  .22881356 6
    . .  .05084746 7
    . .  .59322035 8
    . .  .22881356 6
    . .  .22881356 6
    . .  .59322035 8
    . .  .22881356 6
    . .  .22881356 6
    . .  .22881356 6
    . .  .59322035 8
    . .  .22881356 6
    . .  .22881356 6
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .10169491 5
    . .  .59322035 8
    . .  .22881356 6
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .10169491 5
    . .  .59322035 8
    . .  .10169491 5
    . .  .10169491 5
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .10169491 5
    . .  .59322035 8
    . .  .10169491 5
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .22881356 6
    . .  .10169491 5
    . .  .10169491 5
    . .  .59322035 8
    . . .016949153 3
    . .  .59322035 8
    . .  .22881356 6
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    . .  .59322035 8
    end
    label values occupation_name za_all
    label def za_all 1 "senior management", modify
    label def za_all 3 "technicians", modify
    label def za_all 4 "technicians", modify
    label def za_all 5 "Q.P. commercial act. and services", modify
    label def za_all 6 "craftsmen, farmers, skilled w.", modify
    label def za_all 7 "machinery workers, veichle drivers", modify
    label def za_all 8 "unskilled professions", modify


    were percent1 percent2 perecent3 are the perecentage of individual (divided in 3 different group) that belong to a specific occupation which can range between 1 and 9.
    Thaks a lot for your attention
    Last edited by Enrico Azzini; 07 Feb 2022, 08:54.

  • #2
    Enrico:
    see -table intro- and related stuff in Stata .pdf manual.
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Also

      Code:
      ssc install estout
      You have two groups named "technicians". I merge these below. The result will be in a rtf file, but you can change the format to something else.

      Code:
      preserve
      eststo clear
      foreach var of varlist percent?{
          replace `var'= `var'*100
      }
      recode occupation_name (4=3)
      eststo: estpost tabstat percent*, by(occupation_name)
      esttab using myfile.rtf, replace noobs nonumbers  ///
      cells("percent1(fmt(2)) percent2(fmt(2)) percent3(fmt(2))") ///
      title(Percentage across occupations) varlab(`e(labels)') ///
      collab("Group 1" "Group 2" "Group 3") nomtitle varwidth(40)
      restore
      Res.:

      Code:
      Percentage across occupations
      -------------------------------------------------------------------------------
                                                    Group 1      Group 2      Group 3
      -------------------------------------------------------------------------------
      senior management                                3.21            .            .
      technicians                                     15.50         2.96         1.69
      Q.P. commercial act. and services               18.56            .        10.17
      craftsmen, farmers, skilled w.                  15.05        18.48        22.88
      machinery workers, veichle drivers               7.87         7.60         5.08
      unskilled professions                            8.00        36.94        59.32
      Total                                           11.89        31.40        41.14
      -------------------------------------------------------------------------------

      Comment


      • #4
        Thank you very much

        Comment


        • #5
          Hi Andrew, I tried to repeat this experiment using other data
          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input float(Countryoforign tot_asytt)
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          443 65
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          301 32
          435 28
          435 28
          435 28
          end
          label values Countryoforign t_all
          label def t_all 301 "Afghanistan", modify
          label def t_all 435 "Mali", modify
          label def t_all 443 "Nigeria", modify
          I tried to export table in rtf format. I used the following code
          Code:
           eststo: table Countryoforign if migrant_groupw1==2, c(mean tot_asytt)
          Code:
          -----------------------------
          Countryoforig |
          n             | mean(tot_as~t)
          --------------+---------------
            Afghanistan |             32
             Bangladesh |             14
                   Iraq |             13
               Pakistan |             27
          Cote d'Ivoire |             19
           Burkina Faso |              3
                 Gambia |             26
                  Ghana |             21
                 Guinea |             12
                   Mali |             28
                Nigeria |             65
                Senegal |              8
                Somalia |             17
                Eritrea |             17
          ------------------------------
          than
          Code:
          esttab using myfile.rtf, replace noobs nonumbers cells("tot_asytt(fmt(2))") title (number of refugees per nationalities)
          However, the table showed is empty could you please help me please?

          Comment


          • #6
            You, amico, are interested in estpost.

            Comment


            • #7
              Ok, I made past and copy but the table is empty even with estpost
              Code:
              preserve
              eststo: estpost tabstat tot_asytt if migrant_groupw1==2, by(Countryoforign)
              esttab using myfile.rtf, replace noobs nonumbers   ///
              cells("tot_asytt(fmt(2)) ") ///
              title(Percentage across occupations)  ///
              collab("Group 1") nomtitle varwidth(40)
              restore
              I don't know where I'm wrong

              Comment


              • #8
                The matrix is named -e(mean)-, so you want

                Code:
                cells("mean(fmt(2))"

                Comment


                • #9
                  Thank you very much

                  Comment

                  Working...
                  X