Announcement

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

  • Asdoc makes cell breaks for each blank space in headings and label names

    Hi!

    I find the asdoc command very helpful.
    BUT, for some reason, the resulting tables in word make a cell break for each blankspace.

    This applies both to the automatic headings such as 95% confidence interval,
    and to the text labels of categories in my categorical variables, when they consist of more than one word

    Example:
    Code:
    sysuse auto
    encode make, gen(makeNUM)
    asdoc proportion makeNUM, percent save(filename)  replace
    My results are along the line of the below screendump.
    I get similar results with other commands, and also if I specify the file extension as .doc or .rtf.
    I have STATA 18 and the latest version of Word.
    The biggest problem is when category names have different lengths, then the cells end up being unaligned.
    Click image for larger version

Name:	example asdoc screendump.png
Views:	1
Size:	46.9 KB
ID:	1777078

  • #2
    I do not use asdoc (from SSC), but in case you do not get a reply here, you may want to email the author. With Stata 18, you could get the wanted table using collect. Here is some technique:

    Code:
    sysuse auto, clear
    encode make, gen(makeNUM)
    collect clear
    proportion makeNUM, percent
    
    foreach stat in b se ul ll{
        collect get `stat' = r(table)["`stat'", 1...], tags(var[`stat'])
    }
    collect style cell var, nformat("%9.3f")
    collect label levels var b "Percent"
    collect label levels var se "Std. err."
    collect label levels var ll "Lower 95% CI"
    collect label levels var ul "Upper 95% CI"
    collect layout (colname) (var[b se ll ul])
    collect export mytable, as(docx) replace
    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	93.4 KB
ID:	1777091

    Comment


    • #3
      asdoc does not have a built-in routine for exporting the proportions table. Instead, asdoc constructs the table by capturing the log output generated by Stata’s proportion command. However, this approach may encounter limitations or inconsistencies in certain cases, as the user has noted.

      These limitations have been addressed in asdocx, which offers native support for exporting proportions tables directly, without relying on parsing the log output.
      Code:
      sysuse auto
      encode make, gen(makeNUM)
      asdocx proportion makeNUM, save(filename)  replace
      Click image for larger version

Name:	Capture.JPG
Views:	1
Size:	120.8 KB
ID:	1777116
      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


      • #4
        Thank you, Andrew Musau , that is a nice solution. But I cannot find a way to use it in my case. I'm making an appendix for a report, and need to make a document with upwards of 40+ tables with different analyses. And as far as I can find, "collect" cannot be used with an "append" option to add new tables in the same document?

        Thank you also Attaullah Shah , I will definitely check with my work place if that is a solution for us.

        Thanks both for your quick response, and sorry about my late response!

        Comment


        • #5
          Originally posted by Klara Johansson View Post
          as far as I can find, "collect" cannot be used with an "append" option to add new tables in the same document?
          You can definitely combine tables using collect. The question of how is a bit off-topic here. You might consider starting a new thread titled something like "How to combine two or more tables in the same document using collect."

          Comment


          • #6
            PS - I think I figured out how to solve the above problem using a combination of Andrews code with putdocx and foreach. Thanks again!

            I will come back and show an example of the updated code when I've tested it again and cleaned it up a bit.

            Comment

            Working...
            X