Announcement

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

  • Pasting Stata codes into Microsoft Word

    Hi everyone,
    I am trying to report my Stata code in the appendix of a manuscript which is written in Microsoft Word. A simple way of copying and pasting is not working because some features of state code are missing. This is especially true when the Stata code of interest involves loops or bootstrap. Obviously, an alternative option could be using screenshots of the codes but I wonder if there is a more sufficient way.
    Thanks,
    NM

  • #2
    Perhaps this thread is interesting?

    Comment


    • #3
      Can I ask what features? Do you mean syntax highlighting? My guess is that the Stata do-file editor might not support exporting the highlighting. Not all editors do. . Apparently it is done with RTF. Seems like it might be complicated.

      Comment


      • #4
        I don't understand from #1 what is not working as you expect. Whenever I have needed to do this in MS Office I have just used Courier New or Lucida Console to indicate Stata code for the simple reasons that Stata code looks weird to me unless in some such font and that readers need a strong differentiation between that and other text.

        Comment


        • #5
          Thanks for your comments. The below screenshot represents my problem. What I have pasted in the word is not similar to what I have in the do file. Specifically, the code in the do-file perfectly shows that where the bootstrap begins and where it ends. Also, the colors of the codes is missing when the code is pasted in Microsoft Word.
          Thanks,
          NM


          Click image for larger version

Name:	Screen Shot 2021-11-17 at 2.09.32 PM.png
Views:	1
Size:	1.12 MB
ID:	1636986





          Comment


          • #6
            So, your desires are that MS Word on Macintosh and/or your OS on Mac understand Stata syntax highlighting in the Do-file editor. That's a clear wish for your wishlist. Not sure which company you should be asking there. Any one with work-arounds for this platform will no doubt speak up.

            Comment


            • #7
              What you have copied from your do-file is the text you typed, and it was pasted into Word letter-for-letter perfect.

              What you cannot copy from the do-file editor is the material in the margins that indicate where the program begins and ends. That is a feature of the do-file editor, just as the line numbers are. And as indicated by others, the do-file editor is about creating and modifying plain text - you can't type colored text into the do-file editor and you won't get colored text out of it - the color is, like the line numbers, a presentational feature to benefit the author of the code, not a feature of the text. I notice that when I print text from the do-file editor, syntax highlighting is not included.

              Most programmers take care of using indentation in their code in their do-file to highlight blocks like the code in your program.
              Code:
              capture program drop ... 
              program ...
                  svy ...
                  margins ....
              end
              
              bootstrap ...
              If you put a screenshot into Word you will force anyone interested in adapting your code to retype all the code from the picture, which seems disrespectful of the reader. Better to put in the text and adapt it suitably, including presenting it in a monospace type font such as Courier, and using indentation as a visual aid.

              Comment

              Working...
              X