Stata Code Examples

Reproducible research with Stata

I have recently become aware of a Stata package called MarkDoc. It process the scml file and runs the result through pandoc to produce pdf, html, docx, and other output. It is kind of buggy and not well documented, but the .ado files are small enough to follow and fix if needed.

MarkDoc Package 2.1
MARKDOC: Stata module to convert SMCL logfiles to Markdown format
Dynamic documents in Stata: MarkDoc, Ketchup, and Weaver (pdf)

Examples:

Older stuff:

A collection of commands for Stata, LaTeX, and other programming languages

Stata output as PDF

cd "f:\some\path\"
log using log_file_name, replace
    .
    .
(do some work; produce a graph)
    .
    .
roccomp sepsis logodds_a logodds_b logodds_ab, summary name(some_graph)
    .
    .
graph export some_graph.pdf, replace
   .
   .
log close
translate log_file_name.smcl log_file_name.pdf

About

. about

Stata/IC 13.1 for Windows (64-bit x86-64)
Revision 19 Dec 2014
Copyright 1985-2013 StataCorp LP

Total physical memory:     4191800 KB
Available physical memory: 1736860 KB

Single-user Stata perpetual license:
       Serial number:  301306207433
         Licensed to:  Dale Plummer
                       Vanderbilt

. 

How to draw maps with Stata

In Stata, how to display p-value to higher precision after a regression

*
* Run the regression.
*
poisson total_cost post, exposure(count) irr
*
* Display p-value to higher precision.
*
local z=_b[post]/_se[post]
disp `z'
local p=2*normal(-abs(`z'))
disp "p=`p'"
*
* Here is another way to display to higher precision.
*
estimates table, p(%12.10g)

Running Stata as a batch job

$ cd dirname
$ nohup stata -b do mydofile &

Getting Started with R for Stata Users

http://support.sas.com/software/products/univiewer/

Topic attachments
I Attachment Action Size Date Who Comment
autocode_and_assert_example.dodo autocode_and_assert_example.do manage 4.3 K 24 Mar 2015 - 09:51 DalePlummer example of use of autocode and assert command
descriptives.dodo descriptives.do manage 2.9 K 20 Mar 2015 - 14:32 DalePlummer  
markdoc_markdown.dodo markdoc_markdown.do manage 2.6 K 10 Mar 2015 - 10:51 DalePlummer another contrived example (works better)
sepsis.dodo sepsis.do manage 3.4 K 10 Mar 2015 - 10:48 DalePlummer MarkDoc example using some real code
test.dodo test.do manage 0.2 K 10 Mar 2015 - 10:49 DalePlummer a contrived example to try a few things
Topic revision: r4 - 24 Mar 2015, DalePlummer
 

This site is powered by FoswikiCopyright © 2013-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Vanderbilt Biostatistics Wiki? Send feedback