Lineage and go to definition

Which scripts read and write which files

frds reads Stata do-files, Python scripts, Jupyter notebooks, R, SQL, Julia and LaTeX files and finds the files they read and write: use, merge, save, pd.read_csv, to_parquet, fread, saveRDS, COPY ... TO, CSV.write and many more. It works this out from the text of the scripts. Stata do, run and include count as reading the do-file they run, and a .tex file reads the tables, figures and bibliographies it includes.

Each dataset shows the scripts that create and use it. Each script lists its inputs and outputs and the columns it sets, and flags files that don't exist.

The Lineage tab

The lineage graph following the column ret: the files that have it, the scripts that pass it on or set it, and the files they write. The lineage graph following the column ret: the files that have it, the scripts that pass it on or set it, and the files they write.

The Lineage button, or Ctrl+Shift+L, starts from the file in the active tab and draws what leads to it and what follows from it, one, two or all steps away. The side panel says what a change would affect ("if this changes, 2 scripts and 3 outputs are affected") and what the file depends on. Whole project draws everything, from raw data through scripts to tables, figures and the paper.

The side panel also lists broken links (scripts reading files that don't exist), orphans (datasets no script uses), datasets that look like the same data saved twice, and variables that appear under different names.

Follow a column

Type a column name in the focus box, or choose "Show in lineage" on a variable, to see the datasets that have it, the scripts that set, change, use or pass it on, and every line that names it.

Path variables

Paths are worked out from literal strings, Stata globals, locals and cd, and simple Python, R and Julia variables, os.path.join, pathlib, file.path, joinpath and here(). When a path can't be fully resolved, for example a global root pointing at a co-author's Dropbox, frds links on the trailing folder and file name and marks the link as uncertain.

Tell frds what root stands for on your computer, in Index ▸ Path Variables… or the Lineage panel, and those links resolve exactly. frds suggests the folder when the rest of a path matches one file.

Master do-files often pick the folder by computer (if c(username) == "..." global root ...). With "Use this computer's details to work out paths" turned on in Settings, frds answers c(username), c(hostname), environment variables, Path.home(), os.getenv, Sys.getenv and ~ from this computer and follows the branch for it. It is off by default.

Go to definition

A Stata do-file with the files it reads and writes and the column it sets listed beside the code. A Stata do-file with the files it reads and writes and the column it sets listed beside the code.

In a script, Ctrl+click a name, or click it and press F12, to open where it is defined:

  1. a function, program or table the script defines;
  2. otherwise, the last line above where the script gave the name a value: an assignment, parameter, loop variable, import alias, Stata local, global or tempfile, or a column set;
  3. otherwise, every definition in the project, nearest first.

Right-clicking a name also offers to show it in lineage or search for it.