Doing Less with Stata Markdown

 
Research Computing
Research Computing
 
University of Wisconsin – Madison
 
Doing Less with Stata
Markdown
 
Doug Hemken
 
Stata Conference 2018
 
Wouldn’t it be great
if your papers wrote themselves?
 
 
Stata + Markdown is less ambitious
 
Goals:
Reduce your work combining analysis and
write-up
Easy to read (and to write)
 
 
You provide the code for analysis, and the text,
Stata runs the code and assembles the final
document.
 
What does this look like?
A simple example
 
What you write:
 
Examples\example0.stmd
 
The command you issue:
 
. 
stmd example0.stmd
 
What you get back:
 
Examples\example0.html
 
An Example File
===============
 
Some preliminary text.
 
A code block, evaluted:
```stata
sysuse auto
summarize weight
```
 
In-line text: the mean weight is
`stata %9.1f r(mean)` pounds.
 
A list:
 
- N = `s r(N)`
- mean = `s %9.1f r(mean)`
- sd = `s % 9.2f r(sd)`
 
A graph:
```stata
histogram weight
```
 
More text.
 
Processing in Stata
 
Two Conceptual Layers
 
Markdown
Provides text formatting and document
structure
 
Dynamic Stata code
Provides results from the Results Viewer
 
Stata codes these layers separately, but we can
combine them
 
Markdown cheat sheet
(from Wikipedia)
 
What you write:
Markdown/Wikipedia-markdown.md
 
What you get back (using Stata)
Markdown/Wikipedia-markdown.html
 
Markdown
 
Simplicity – readability and writability are
the central themes
There are many Markdown variants
(None are documented in full detail)
Stata implements two of these:
Flexmark (default)
Pegdown (an undocumented option)
 
These are used with a few dozen of
programming languages for dynamic code
 
Markdown and Dynamic code
 
Most implementations embed dynamic
code in
Fenced code blocks
 with 
information tags
In-line code
, also with an information tag
 
Stata is much more flexible – dynamic code
need not be formatted as <code>.  The price
of this flexibility, however, is readability.
 
What does this look like?
 
What you write:
 
Examples\example0.dyn
 
The Stata process
 
The stmd process
 
Implications
 
Less writing, cleaner writing
Automate graphics links
Compatability (with markstat, R knitr)
 
Raw dynamic tags (e.g. <<dd_remove>>,
<<dd_skip_if>>) can be included, as can raw
HTML (e.g. complicated <table> structures).
 
Code Block options
 
nocommands
nooutput
quietly
noprompt
 
Essentially the options for <<dd_do>>.  There
are alternative formulation for compatability
with R knitr.
 
More examples
 
What you write:
Examples/example-codeopts.stmd
 
What you get back:
Examples/example-codeopts.html
 
stmd usage
 
 
stmd 
filename
 [, 
sav
ing(
filename2
)
   
replace 
dyndoc-options
]
 
Download/ install
 
net from
https://www.ssc.wisc.edu/~hemken/Stataworkshops
 
Tinker with the source code, suggest improvements:
https://github.com/Hemken/stmd
Slide Note
Embed
Share

Explore how Stata Markdown simplifies the process of combining analysis and write-up, making it easy to read and write. Learn about the integration of Markdown with dynamic Stata code to automate document assembly, providing a seamless workflow for researchers and analysts.

  • Stata Markdown
  • Data Analysis
  • Research Writing
  • Document Automation

Uploaded on Aug 11, 2024 | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Doing Less with Stata Markdown Doug Hemken Stata Conference 2018

  2. Wouldnt it be great if your papers wrote themselves?

  3. Stata + Markdown is less ambitious Goals: Reduce your work combining analysis and write-up Easy to read (and to write) You provide the code for analysis, and the text, Stata runs the code and assembles the final document.

  4. What does this look like? A simple example What you write: Examples\example0.stmd The command you issue: . stmd example0.stmd What you get back: Examples\example0.html

  5. Processing in Stata

  6. Two Conceptual Layers Markdown Provides text formatting and document structure Dynamic Stata code Provides results from the Results Viewer Stata codes these layers separately, but we can combine them

  7. Markdown cheat sheet (from Wikipedia) What you write: Markdown/Wikipedia-markdown.md What you get back (using Stata) Markdown/Wikipedia-markdown.html

  8. Markdown Simplicity readability and writability are the central themes There are many Markdown variants (None are documented in full detail) Stata implements two of these: Flexmark (default) Pegdown (an undocumented option) These are used with a few dozen of programming languages for dynamic code

  9. Markdown and Dynamic code Most implementations embed dynamic code in Fenced code blocks with information tags In-line code, also with an information tag Stata is much more flexible dynamic code need not be formatted as <code>. The price of this flexibility, however, is readability.

  10. What does this look like? What you write: Examples\example0.dyn

  11. The Stata process Dynamic Markdown dyntext (to markdown) dyndoc (to markdown, to HTML) Markdown markdown HTML browser

  12. The stmd process Standard dynamic Markdown stmd2dyn stmd dyndoc- HTML Stata dynamic Markdown dyntext, dyndoc Markdown markdown HTML browser

  13. Implications Less writing, cleaner writing Automate graphics links Compatability (with markstat, R knitr) Raw dynamic tags (e.g. <<dd_remove>>, <<dd_skip_if>>) can be included, as can raw HTML (e.g. complicated <table> structures).

  14. Code Block options nocommands nooutput quietly noprompt Essentially the options for <<dd_do>>. There are alternative formulation for compatability with R knitr.

  15. More examples What you write: Examples/example-codeopts.stmd What you get back: Examples/example-codeopts.html

  16. stmd usage stmd filename [, saving(filename2) replace dyndoc-options]

  17. Download/ install net from https://www.ssc.wisc.edu/~hemken/Stataworkshops Tinker with the source code, suggest improvements: https://github.com/Hemken/stmd

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#