Rethinking literate programming in statistics

E. F. Haghish*

*Corresponding author for this work

Research output: Contribution to journalJournal articleResearchpeer-review


Literate programming is becoming increasingly trendy for data analysis because it allows the generation of dynamic-analysis reports for communicating data analysis and eliminates untraceable human errors in analysis reports. Traditionally, literate programming includes separate processes for compiling the code and preparing the documentation. While this workflow might be satisfactory for software documentation, it is not ideal for writing statistical analysis reports. Instead, these processes should run in parallel. In this article, I introduce the weaver package, which examines this idea by creating a new log system in HTML or LATEX that can be used simultaneously with the Stata log system. The new log system provides many features that the Stata log system lacks; for example, it can render mathematical notations, insert figures, create publication-ready dynamic tables, and style text, and it includes a built-in syntax highlighter. The weaver package also produces dynamic PDF documents by converting the HTML log to PDF or by typesetting the LATEX log and thus provides a real-time preview of the document without recompiling the code. I also discuss potential applications of the weaver package.

Original languageEnglish
JournalStata Journal
Issue number4
Pages (from-to)938-963
Publication statusPublished - 2016



  • Div
  • Dynamic documents
  • HTML
  • Img
  • LTX
  • Literate programming
  • Log
  • Pr0063
  • Reproducible research
  • Tbl
  • Txt
  • Weave
  • Weaver
  • Weaving

Cite this

Haghish, E. F. (2016). Rethinking literate programming in statistics. Stata Journal, 16(4), 938-963.