do2screen is a Stata package for reviewing specific sections of a do-file directly in the Stata console. It helps you trace how variables were built, find relevant strings with context, and inspect selected line ranges without manually scrolling through long scripts.
- Documentation site: https://randrescastaneda.github.io/do2screen/
- Source code: https://github.com/randrescastaneda/do2screen
- License: MIT
Trace the lines where a variable is created, modified, or dropped.
By default, do2screen also follows parent variables recursively, so if income depends on wages and transfers, it will also show how those were built.
do2screen using "analysis.do", var(pchincome)Useful for:
- auditing derived variables
- understanding long production scripts
- reconstructing variable lineage across a project
Find a word or phrase in a do-file and show the matching lines plus surrounding context.
do2screen using "analysis.do", find("poverty line") lines(10)Useful for:
- locating definitions or comments
- finding sections related to a topic
- reviewing logic around a known string
Display any selected block of a do-file by line number.
do2screen using "analysis.do", range(253 263)Useful for:
- inspecting a narrow region of code
- sharing exact segments with collaborators
- exporting specific sections to text output
First install E. F. Haghish's github package if needed:
net install github, from("https://haghish.github.io/github/")Then install do2screen:
github install randrescastaneda/do2screennet install do2screen, ///
from("https://raw.githubusercontent.com/randrescastaneda/do2screen/master/") ///
replacedo2screen is also available on SSC, but the SSC copy may lag behind the GitHub version. For the latest release and documentation, install from GitHub.
- Stata 16.1 or higher
do2screen v5.0 uses Stata frames internally.
do2screen using "analysis.do", var(income)do2screen using "analysis.do", var(income) nopreviousdo2screen using "analysis.do", find("poverty")do2screen using "analysis.do", range(50 75)do2screen using "analysis.do", var(income) text("output/income_trace") replaceFor full usage details, examples, and option reference, see:
The site includes:
- a getting started guide
- a full reference page
- articles on variable tracing, find/range, and caveats
Repository contents include:
do2screen.adoand helper_do2screen_*.adofilesdo2screen.sthlptests/golden-file regression testsdocs/site/Quarto documentation source
To run the test suite from Stata:
do "tests/run_tests.do"- R. Andres Castaneda — The World Bank
- Santiago Garriga — Universidad Nacional de La Plata
This package is licensed under the MIT License. See LICENSE for details.