Stata Blog: Applied Statistics Using Stata

Applied Statistics Using Stata

Free Online Stata Tips & Tutorials. Data Management; Stata Graphs and Graphics; Data Analysis; Stata Programming; Advanced Statistics

MarkDoc Package 1.4


| Quick Tips |    
| Introduction |    
| Graphs |    
| Installation |    
| Pandoc |    
| PDF |    
| Docx |    
| Examples |    
| Source File |    

Quick Tips

MarkDoc converts a smcl logfile to Microsoft Office docm (recommended), docx, doc, OpenOffice/LibreOffice odt, Markdown md, LaTeX tex and dvi, html, xhtmL, OpenDocument xml, epub, ReStructuredText rest, AsciiDoc txt, textile, FictionBook2 fb2, and Outline formats opml. Note that MarkDoc requires additional software that are downloaded and installed automatically once you begin working with MarkDoc. But you need to be the Administrator of your machine. Here are a few examples of how to install and update MarkDoc and also, how to export a Markdown, HTML, and a Microsoft Word document.

Introduction

While I was working on Stata Weaver Package, I tried to find the easiest way to write text in Stata Do-file Editor. I wrote several programs, some in Stata, some in JavaScript to ease the task. But, none was good enough. A good enough program means that it solves a problem in a way that other people would not attempt to solve it again. This is partly due to the fact that there are several programs generating dynamic reports in Stata but none has really made writing in Stata a cheerful experience.

The idea of MarkDoc program hit my mind when I thought about creating a Markdown file directly from Stata logfile. Such a translator could create a markdown text file (*.md) which not only includes the Stata commands and the outputs but also Markdown syntax. Then I could Pandoc software to convert the Markdown file to any other format supported by Pandoc. This could also allow us to include graphs and images in the exported document which are imported with Markdown syntax.

See also  Converting data formats with R

MarkDoc was written to carefully process Stata commands and comments. I figured out the the best way to wite Markdown syntax in the do-editor is to write them as a comment. This would separate human language from computer language also by highlighting them with different colors (by default, comments appear in green color in Stata).

To use MarkDoc, all you need to do is creating a logfile, doing your data analysis, and insert comments with markdown signs whenever you want to write or comment a result. At the end, use the MarkDoc program to translate the smclfile into markdown. If you install Pandoc on your machine, you can also export the smclfile into tens of formats that Pandoc supports. I have written as article about How To Write Text In Do-Edit. I also wrote an article about Writing With Markdown Syntax. Check that out, it will give you an idea how to use MarkDoc properly.

Warning: MarkDoc requires additional software which are downloaded and installed automatically from Stata. You most open Stata as an Administrator to have the permission of installing the required software. If you are working from your personal computer or a machine where you are the administrator, you do not need to worry. However, if Stata is installed on a server or computers where you only are a Standard user, ask the administrator to install the software.

Graphs and Image

Markdown codes can be applied to insert an image or graph to the output. For example, you can export a Microsoft Docx ,PDF, or HTML document that includes graphs. To learn how to insert a graph using Markdown syntax, read the article I have written about writing in Stata using Markdown. Also, see the markdoc_ilovestata.do example below.

See also  Exploring the Latest Breakthroughs in 3D Printing Technology

Installation

To install MarkDoc on your Stata, type the following command:

Make sure you check once in a while that there is no new update for MarkDoc. To keep MarkDoc updated, type the following command in your Stata console:

Pandoc

Pandoc is a third-party program that converts a Markdown file to the following formats. The MarkDoc package only creates a Markdown file which is a text file with the (.md) file extention. When pandoc is installed on your Machine, the package automatically reach outs for Pandoc and export the Markdown file to other formats. I have published a complete guide about installing Pandoc for Stata. Click here to read the article

PDF

Pandoc cannot export PDF on its own and relies on LaTeX instead. Microsoft Windows users may install MiKTeX if they don’t wish to install the complete LaTex tools. Macintosh users may install BasicTeX instead. Unix users may try TeX Live. More importantly, the path to the PDF LaTeX engine should be given to MarkDoc using the tool(string) option.

Docx

Microsoft Word Docx documents, exported from Pandoc have a relatively large margin. Therefore to show the tables, you may want to decrease the margins of the document. Alternatively, you can reduce the linesize of your Stata output to 70 or 60. to do so, type:

Example templates

Download the following do-files templates to see examples of how to use the MarkDoc package properly. Right click and select “Save Link As” to download the files.

markdoc_example1.do

markdoc_ilovestata.do

Download source file

While writing the package, I tried to comment the procedure as clear as possible, assuming some of you would be interested to look into it. Here you can download the do-file of the program, along with the comments. Right click on the link below and save as the program.

See also  Retina X Studios, LLC - Monitoring Software for Remote Internet Tracking of Computers and Smartphones - About the Company.

markdoc.ado version 1.3

back to top

Scroll to Top