Announcement

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

  • Problem with bysort and tabulate using asdoc

    Hi all,

    I wonder if its possible use asdoc with bysort: and tabulate example

    Code:
    sysuse auto.dta
    bys foreign: asdoc tab rep78
    Result its not that I expected

    Code:
         Repair |
    Record 1978 |      Freq.     Percent        Cum.
    ------------+-----------------------------------
              1 |          2        2.90        2.90
              2 |          8       11.59       14.49
              3 |         30       43.48       57.97
              4 |         18       26.09       84.06
              5 |         11       15.94      100.00
    ------------+-----------------------------------
          Total |         69      100.00
    Click to Open File:  Myfile.doc
    I grateful any coments
    Thanks

  • #2
    Presently, the bysort prefix does not work with tabulation commands. I shall work on it in the next update. In the meanwhile, one workaround is to use a loop and estimate the tabulation of the given variables for each distinct value of the bysort variable. So
    Code:
    levelsof foreign, local(levels)
    foreach v of local levels{
    asdoc tab rep78 if foreign == `v', save(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


    • #3
      Dear Attaullah Shah,

      Thanks for you reply as always yours solutions works great!

      Just one question, its possible get percent in a side column? and not below frequency value), like original tabulate table?.

      Regards and thanks in advance
      Rodrigo

      Comment


      • #4
        Is it possible to use asdoc with sum and bysort?


        Code:
        bysort countryyr: asdoc sum foodinsecure genderlaws genderviews, detail
        Using Stata 15.1

        Comment


        • #5
          Yes, it is possible. see the following example. For more tips and tricks on summary statistics with asdoc, you can watch this YouTube video

          Code:
          webuse grunfeld
          bysort company: asdoc sum invest mvalue kstock , stat(N mean sd min max p1 p50 p75 skewness kurtosis) replace
          Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	74.9 KB
ID:	1499202

          Last edited by Attaullah Shah; 20 May 2019, 16:28.
          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


          • #6
            When I complete this command, only one of my Level2 variables shows up in the word document.

            Comment


            • #7
              Cannot tell much without seeing an example of your dataset and the code that you have used. You can post a sample of your data using dataex (from SSC)
              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
                Originally posted by Attaullah Shah View Post
                Cannot tell much without seeing an example of your dataset and the code that you have used. You can post a sample of your data using dataex (from SSC)
                . bysort foreign: asdoc sum price mpg headroom weight, stat(mean) append
                foreign
                ' invalid name
                (error in option by())
                r(198);

                Comment


                • #9
                  Dear Prof. Shah, thank you for writing this excellent program. I am using stata16.1 and reinstalled the latest version of asdoc by yesterday though the version I read at the top right corner of the help notes page is still as before (version 2.3.7.0). I need your help on a couple of issues.
                  1) bysort option is not working for me with sum (when stat option is used) and tabstat commands even using the dataset and commands you used for illustration. I get the same error when I used my own data too. How can I fix it please? Below are the different commands I wrote and the error message I got.

                  . bysort foreign: asdoc tabstat price mpg rep78 headroom trunk weight length, stat(mean) replace
                  foreign
                  ' invalid name
                  (error in option by())
                  r(198);

                  . asdoc tabstat price mpg rep78 headroom trunk weight length, stat(mean) by(foreign) replace
                  foreign
                  ' invalid name
                  (error in option by())
                  r(198);

                  . bysort foreign: asdoc sum price mpg headroom weight, stat(mean) append
                  foreign
                  ' invalid name
                  (error in option by())
                  r(198);


                  2) Turning to my second question, bysort option works with tabulate command. But, it makes a separate table for each category. Is there any mechanism to reorganize the stats of each category as a single table?

                  Thank you!
                  Last edited by Abe Habeshaw; 03 Oct 2020, 11:10.

                  Comment


                  • #10
                    Abe Habeshaw There was one additonal characters with a macro, I have removed that and now asdoc should work as normal. The new version of asdoc
                    Code:
                    (Version 2.3.8.78 : Changes made on October 5, 2020 )
                    can be installed from my site. Copy and paste the following line in Stata and press enter.

                    Code:
                    net install asdoc, from(http://fintechprofessor.com) replace
                    Please note that the above line has to be copied in full. After installation of the new version, then restart Stata.


                    2) You may kindly suggest the format in which the multiple categories can be reported when we used bysort with tabulate.


                    Please do remember to cite asdoc. To cite:
                    In-text citation
                    Tables were created using asdoc, a Stata program written by Shah (2018).

                    Bibliography
                    Shah, A. (2018). ASDOC: Stata module to create high-quality tables in MS Word from Stata output. Statistical Software Components S458466, Boston College Department of Economics.
                    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


                    • #11
                      Dear Prof. Shah, thank you for your hard work and reply!
                      1) bysort option works now pretty well with tabstat using the new version of asdoc. One minor comment on this is it does not include the total row. It would be great if asdoc includes statistics of the total row at the bottom of the group, as stata does.

                      2) my suggested format regarding my second question is as follows

                      Click image for larger version

Name:	Screenshot 2020-10-06 144402.png
Views:	1
Size:	23.4 KB
ID:	1575731



                      Thank you!
                      Abe

                      Comment

                      Working...
                      X