An advantage of Pandoc pipe tables is that they can easily be combined with inline code to produce dynamic tables. Here is an example generating a table showing average gallons per 100 miles for foreign and domestic cars before and after adjustment for weight. We use a strict code block to te able to hide the commands and quietly to supress output, and then display the stored results in a pipe table.This is the input:
% A Dynamic Table ```s/ quietly sysuse auto, clear quietly gen gphm = 100/mpg quietly regress gphm foreign mat b = e(b) quietly sum weight scalar mw = r(mean) quietly reg gphm weight foreign scalar dom = _b[_cons] + _b[weight] * mw local f %6.2f ``` The table below shows average fuel efficiency in gallons per 100 miles for foreign and domestic cars before and after adjustment for weight: | Car Type | Unadjusted | Adjusted | |:-----------|----------------------:|--------------------------:| | Foreign | `s `f' b[1,1]+b[1,2]` | `s `f' dom + _b[foreign]` | | Domestic | `s `f' b[1,2]` | `s `f' dom` | Foreign cars use less fuel than domestic cars but are also lighter, when we compare cars with the same weight the imports use six-tenths of a gallon more per 100 miles than the domestic cars.
And this is how this is rendered by the command
markstat using dynatab.
As usual, you can reproduce this example by typing
copy https://grodri.github.io/markstat/dynatab.stmd . markstat using dynatab
You need to download the script first because
markstat works with local files.