Chat Q & A: Incorporating Stata into reproducible documents—Webpages, Word, and PDF

Participants of the webinar Incorporating Stata into reproducible documents—Webpages, Word, and PDF, which took place on February 6, 2018, asked StataCorp developers the following:

Question: I often use tabulate to get the percentages for a variable. Is there an easy way to access those percentages? Return list does not allow that.
Answer: Try using the proportion command to get proportions. It returns r(table).
Question: Does cls also clear the dataset from memory?
Answer: No, cls clears only the Results window.
Question: When you have text within the <<dd_do>> and <</dd_do>>, does that mean the commands begin and end there?
Answer: The <<dd_do>> switches into Stata running commands (so it goes into execute mode, in a way), and <</dd_do>> ends the execution mode.
Question: What is the doed command?
Answer: doed opens the do-file editor. It can take a file name so that it makes it simple to open do-files within the working directory.
Question: Is it possible to not have the Stata tables and code in the document, so just text and explanation?
Answer: Yes, the <<dd_do>> tag has an attribute (like an option) which squelches input, output, or both.
Question: Can we change the font of the output? If I don't like the default font, how can I change it?
Answer: The file that is being created is just a text file. You can change the font in the do-file editor or bring the text into a text editor.
Question: Is there a reason to pull the coefficient out of a matrix rather than using _b[weight]?
Answer: Not really.
Question: Is there a way to change the format of the tables Stata produced so they will look more professional and less like computer output?
Answer: Yes, some of this will come as the webinar progresses.
Question: Just to make sure, only commands between<<dd_do>> and <</dd_do>> are run?
Answer: Yes. Everything else in the file looks like text to dyndoc.
Question: Is there a possibility to show the command ouput but not the command line in the report (in HTML)?
Answer: Yes, <<dd_do: nocommand>> will squelch the command and leave the output.
Question: Do dynamic tags function in Stata 14?
Answer: The dynamic tags are new in Stata 15, so they are not available in Stata 14.
Question: Is there a way to enter data into Excel formatted as tables?
Answer: That would need to be done via putexcel rather than by using dyndoc.
Question: How is the Word formating controlled? Headings, etc.
Answer: There are some settings for the headings and such.
Question: When we generate an HTML output with more than one HTML page (documents), is there a possibility to generate an INDEX (typically a column on one side) to navigate among different pages?
Answer: That's more of an HTML issue, so I would think that would be controlled by the header of the HTML file. Something like what Hua had calling his CSS file.
Question: Can the results be saved out to a Word document using a particular type of formatting, such as APA style?
Answer: The documents created by putdocx live up to the standards of the open docx format. This means that the documents are like Open Office documents, so anything that would work with Open Office should work with our files.
Question: Is putdocx available in Stata 14?
Answer: putdocx is new in Stata 15. It is not available in Stata 14.
Question: Do we currently have a way to toggle options for tables in Word like "Repeat header on each page"?
Answer: Use the headerrow() option on the putdocx table command that creates the table.
Follow up: That will work for the Header of the Word document, and not just a table.
Answer: No, just for the table.
Question: Can you explain again what ∼∼∼∼ does in dyndoc ... I did not get exactly what it does.
Answer: It a fenced code block, so the text will appear in webpages as it is in text files, without being reformatted to paragraph mode. You put 4 ∼ before the block and 4 ∼ after the block. A good reference for Markdown is https://daringfireball.net/projects/markdown/syntax.
Question: Do the commands <<dd_do>> apply on putdocx?
Answer: No. The two commands are very different. dyndoc is in narrative mode and switches to execution via <<dd_do>>. putdocx is always in execution mode.
Question: How are dynpandoc and putdocx related? Better yet, how do they differ? When would I use dynapandoc and not putdocx?
Answer: If you need tables being formatted in certain ways, use putdocx. If you want Stata output in the report, use dynpandoc.

If you have additional questions about the webinar or about incorporating Stata into reproducible documents, please contact our technical services department.