Build interactive HTML dashboards, calculators, and searchable data tables straight from Stata — no web development required.
statashiny turns Stata variables and coefficients into a single .html file with live, interactive widgets:
- Searchable, sortable data tables (powered by DataTables)
- Live charts that recompute in the browser as you move sliders (powered by Chart.js)
- Value cards, numeric inputs, checkboxes laid out with Bootstrap 5
You write Stata; statashiny writes the HTML, CSS, and JavaScript. The output is one portable file (it loads its libraries from CDNs, so the viewer needs internet) you can email, drop on a shared drive, host on GitHub Pages, or embed inside a webdoc2 report with an <iframe>.
🔗 See it live: ericabooth.github.io/StataShiny_Example_Site — a working example site built entirely with
statashiny(+webdoc2) and hosted free on GitHub Pages.
A static regression table shows one number. A statashiny dashboard lets your audience explore:
- Scenarios — "What happens to predicted price if MPG rises 10%?"
- Interactions — "How does origin change the weight–price relationship?"
- Uncertainty — watch confidence bands widen as simulated N shrinks.
And because the output is plain HTML with CDN-loaded libraries, there's nothing to install for the viewer — it opens in any browser. The libraries load from public CDNs when the page opens, so viewing needs an internet connection.
statashiny is standalone — for basic dashboards it has no Stata dependencies (the interactive libraries load from public CDNs in the browser at view time).
net install statashiny, from("https://raw.githubusercontent.com/ericabooth/StataShiny-public/main/") replace force
discard
which statashiny
help statashinyRequires Stata 16+. To also build full report pages around your dashboards (as in the combined example below), install webdoc2 too — but that's optional.
Manual install: drop statashiny.ado and statashiny.sthlp anywhere on your Stata adopath.
A searchable, sortable table from data in memory — three commands:
sysuse auto, clear
collapse (mean) price mpg weight length (count) n=price, by(foreign)
label var price "Mean Price ($)"
statashiny, title("Auto Summary Table") replace
statashiny autotab, output(table) label("Descriptives by Origin") ///
vars(foreign price mpg weight length n)
statashiny, build export("dashboard.html") openopen pops it straight into your browser. That's the whole workflow:
statashiny, title(...) replace— start a new dashboard (replaceclears the previous dashboard's components;buildalways overwrites the export file)- add inputs / outputs (
output(table),output(val),input(num),input(check), …) statashiny, build export("file.html") open— write the HTML and open it
The full example is examples/standalone_dashboard.do.
examples/mwe_statashiny.do builds one HTML report that contains:
- a narrative + simple analysis (summary stats and a collapsible regression) via
webdoc2, - an interactive table widget, and
- an interactive visualization (a live histogram simulator),
with the two widgets embedded as iframes. Build it with:
webdoc2 mwe_statashiny.do, open cleanupThe shape of the do-file:
* 1. Build the interactive TABLE widget -> shiny_table.html
sysuse auto, clear
collapse (mean) price mpg weight length (count) n=price, by(foreign)
label var price "Mean Price ($)"
statashiny, title("Auto Summary Table") replace
statashiny autotab, output(table) label("Descriptives by Origin") ///
vars(foreign price mpg weight length n)
statashiny, build export("shiny_table.html")
* 2. Build the interactive VISUALIZATION widget -> shiny_viz.html
statashiny, title("Live Histogram Simulator") replace
statashiny obs, input(num) label("Sample Size") val(1000) min(100) step(100)
statashiny bins, input(num) label("Number of Bins") val(20) min(5) max(50)
statashiny chart_container, output(val) label("Simulated Normal Histogram")
statashiny, calc("if (!window.hChart) { ... Chart.js setup ... }")
statashiny, calc("... read inputs, build histogram, hChart.update(); ")
statashiny, build export("shiny_viz.html")
* 3. Build the report page that embeds them both
wdinit mwe_statashiny, replace
wputh1 Analysis
wd
sysuse auto, clear
summarize price mpg weight length
wdclose
wputh1 Interactive Table
wdiframe shiny_table.html, height(480px)
wputh1 Interactive Visualization
wdiframe shiny_viz.html, height(620px)
webdoc closeRun it and you get mwe_statashiny.html (open this), plus shiny_table.html and shiny_viz.html beside it.
⚠️ iframe gotcha (read this). When you open the report by double-clicking it (afile://URL), browsers only let an iframe load files from the same folder. So alwaysexport()your widgets with a plain filename (no path) — that writes them next to the report — and reference them with a plain filename inwdiframe/<iframe src=...>. If a panel shows up blank, this is almost always why. (Hosting the folder on a web server, like GitHub Pages, removes the restriction entirely.)
| Command | What it makes |
|---|---|
statashiny, title(...) replace |
Start a new dashboard |
statashiny ID, output(table) vars(...) |
Searchable/sortable DataTable from variables in memory |
statashiny ID, output(table) vars(...) toggles |
…plus auto checkboxes to show/hide each column |
statashiny ID, output(val) label(...) [prefix() suffix()] |
A value "card" that JavaScript fills in |
statashiny ID, output(raw) label("<...html...>") |
Drop in arbitrary HTML (e.g. a chart container) |
statashiny ID, input(num) val() min() max() step() |
A numeric input the user can change (no limits unless min()/max() are given) |
statashiny ID, input(check) [checked] |
A checkbox |
statashiny, calc("...JS...") |
Add JavaScript to the live updateDashboard() function (use compound quotes, calc(`"...JS with "quotes"..."'), when the code holds a double quote) |
statashiny, build export("file.html") [open] |
Write the HTML (and optionally open it) |
Full reference with six worked examples (searchable table, CI explorer, policy simulator, histogram, difference-in-differences, dynamic UI): help statashiny.
The demo at ericabooth.github.io/StataShiny_Example_Site is just statashiny output committed to a repo with Pages turned on:
- Put your built
.htmlfiles (report + widgets, all in one folder) in a GitHub repo. - Repo Settings → Pages → Source: Deploy from a branch, pick
mainand/ (root). - Your site goes live at
https://<user>.github.io/<repo>/<file>.html.
Because Pages serves over https://, the file:// iframe restriction disappears — widgets in subfolders, external links, and absolute paths all work.
-
1.5.4 (9 Nov 2026): the abbreviations
c(),o(raw)andl()work; they were accepted and silently dropped.calc()code wrapped in compound quotes reaches the page without the delimiters (they were a JavaScript syntax error that disabled the whole dashboard). Double quotes intitle(),label(),prefix()andsuffix()no longer stop the command.min()andmax()are written only when given; they used to default to -1000 and 1000, which capped larger values. An unknowninput()oroutput()type is an error.export()expands a leading~and accepts backslash and UNC paths. -
1.5.3 (9 Nov 2026): string values, variable labels and value labels that contain a line break or
</script>no longer break the page. Before, one such value made every table on the page render empty whilebuildstill reported success.
Eric A. Booth, Sr Researcher, Texas 2036 (eric.a.booth@gmail.com).
Issues and PRs welcome at github.com/ericabooth/StataShiny-public.