Announcement

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

  • tabout command generating an easy cross table in word

    Hey,
    I try to create an easy cross table.
    First, I used the tabulate command: tabulate variable1 variable2, column.
    Now I would like to get the same output directly in MSWord. For that I tried to use the tabout command. Unfortunately with this command the numbers for one column are nor listed underneath one column and a nice grid with lines is not produced either.
    This is how my command looks like atm: tabout variable1 variable2 name.doc, replace cell(col) h1(heading) h3(heading)

    Thanks for your help!
    Jana

  • #2
    Exporting output from Stata to MS Word is super easy with asdoc (can be downloaded from SSC). Following is one example of two-way tabulations. There are dozens of examples in the asdoc help file for exporting output from other Stata commands.
    Code:
    ssc install asdoc
    help asdoc
    sysuse auto, clear
    asdoc tabulate rep78 foreign , replace
    Click image for larger version

Name:	tabulate asdoc.png
Views:	1
Size:	11.7 KB
ID:	1476259


    Here is a short blog entry on asdoc http://fintechprofessor.com/2018/02/...basic-example/
    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
      Thank you very much! That command helps a lot!
      With it I am able to create the following table.

      Table 1 - Distribution of Looks
      Key
      -------------------
      frequency
      column percentage
      +-------------------+
      =1 if female
      from 1 to 5 Men Women Total
      Homely 8 5 13
      0.97 1.15 1.03
      Below average 88 54 142
      10.68 12.39 11.27
      Average 489 233 722
      59.34 53.44 57.30
      Above average 228 136 364
      27.67 31.19 28.89
      Strikingly beautiful 11 8 19
      1.33 1.83 1.51
      Total 824 436 1,260
      100.00 100.00 100.00
      Do you know how I to delete the unuseful information below the table title? In particular I would like to have "Category" instead of "from 1 to 5"!

      Comment


      • #4
        From the output you posted, it is hard to guess how your data looks like. Please post a sample of your data using dataex(from SSC). Please also post the code that you typed in Stata to generate the above table.
        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
          This is a sample of my data:
          ​​​​​​input float(wage lwage) byte(belavg abvavg exper looks union goodhlth black female married south bigcity smllcity service) int expersq byte educ
          5.73 1.7457155 0 1 30 4 0 1 0 1 1 0 0 1 1 900 14
          4.28 1.453953 0 0 28 3 0 1 0 1 1 1 0 1 0 784 12
          7.96 2.074429 0 1 35 4 0 1 0 1 0 0 0 1 0 1225 10
          11.57 2.4484155 0 0 38 3 0 1 0 0 1 0 1 0 1 1444 16
          11.42 2.435366 0 0 27 3 0 1 0 0 1 0 0 1 0 729 16
          3.91 1.3635374 0 0 20 3 0 0 0 1 1 0 1 0 0 400 12
          8.76 2.1701958 0 0 12 3 0 1 0 0 1 0 1 0 0 144 16
          7.69 2.0399208 0 1 5 4 1 1 0 0 0 0 0 1 0 25 16
          5 1.609438 0 0 5 3 0 1 0 1 0 0 0 0 0 25 16
          3.89 1.358409 0 0 12 3 0 1 0 1 0 0 0 1 0 144 12
          3.45 1.2383742 0 1 3 4 0 1 0 1 0 0 1 0 0 9 12
          4.03 1.3937664 0 1 6 4 0 1 0 0 1 0 0 1 0 36 16
          5.14 1.637053 1 0 19 2 0 1 0 0 1 0 0 1 1 361 17
          3 1.0986123 0 0 8 3 0 1 0 0 0 0 0 1 1 64 16
          7.99 2.0781908 0 1 12 4 0 1 0 0 1 0 0 0 0 144 16
          6.01 1.793425 0 1 17 4 0 1 0 0 1 0 0 1 0 289 16
          5.16 1.6409365 0 0 7 3 0 1 0 0 1 0 0 0 0 49 17
          11.54 2.445819 0 1 12 4 0 1 0 0 1 1 0 1 1 144 17
          10.44 2.3456445 0 1 10 4 0 1 0 1 0 0 1 0 0 100 17

          That is the code I used for the table:
          asdoc tabulate looks female, replace column title(Table 1 - Distribution of Looks)

          Comment


          • #6
            You can suppress the additional details with option nokey.
            Code:
            asdoc tabulate looks female, replace column title(Table 1 - Distribution of Looks) nokey
            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


            • #7
              I tried using the nokey option but unfortunately it doesn't work

              Comment


              • #8
                Your answer does not tell much what did not work for you. I can guess that you are referring to an earlier post where you mentioned that you would like to have the text "Category" instead of "from 1 to 5!" This specific text is coming from your variable label. You can change the label of the given variable to Category
                Code:
                label var looks "Category"
                asdoc tabulate looks female, replace column title(Table 1 - Distribution of Looks) nokey
                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


                • #9
                  Jana Michel I have spent the last 2 days in totally revamping the tabulate command The new version of asdoc creates really elegant tables from the tabulate command. I hope that you will like it You can install this beta version from my website. Please copy and paste the following three lines in Stata command window and press enter

                  Code:
                  net install uninstall_asdoc, from(http://fintechprofessor.com) replace
                  
                  uninstall_asdoc
                  
                  net install asdoc, from(http://fintechprofessor.com) replace
                  Few Examples from the new version are here

                  one-way tabulate
                  Code:
                  sysuse nlsw88
                  asdoc tabulate occupation, replace
                  Click image for larger version

Name:	asdoc tabulate 1.png
Views:	1
Size:	38.0 KB
ID:	1476660



                  Two-way tabulate
                  Code:
                  asdoc tabulate  occupation race, replace
                  Click image for larger version

Name:	asdoc tabulate 2.png
Views:	1
Size:	43.4 KB
ID:	1476661



                  Two-way tabulate with row percentages
                  Code:
                  asdoc tabulate  occupation race, row replace
                  ​​​​​​​
                  Click image for larger version

Name:	asdoc tabulate 2 row.png
Views:	1
Size:	42.7 KB
ID:	1476662
                  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

                  Working...
                  X