Using «dd_do»

Let us consider an example where we study the mpg and weight variables in auto.dta. In our examples below, we will first write the commands so that they will be displayed in our target HTML file. Then, we will write the commands so that Stata will process the Stata dynamic tags, displaying the results of the Stata commands in the target HTML file.

<<dd_do>>
sysuse auto, clear
describe
<</dd_do>>

This produces the following Stata results:

. di c(linesize)
88

. sysuse auto, clear
(1978 Automobile Data)

. describe

Contains data from D:\Programs\Stata15\ado\base/a/auto.dta
  obs:            74                          1978 Automobile Data
 vars:            12                          13 Apr 2016 17:45
 size:         3,182                          (_dta has notes)
----------------------------------------------------------------------------------------
              storage   display    value
variable name   type    format     label      variable label
----------------------------------------------------------------------------------------
make            str18   %-18s                 Make and Model
price           int     %8.0gc                Price
mpg             int     %8.0g                 Mileage (mpg)
rep78           int     %8.0g                 Repair Record 1978
headroom        float   %6.1f                 Headroom (in.)
trunk           int     %8.0g                 Trunk space (cu. ft.)
weight          int     %8.0gc                Weight (lbs.)
length          int     %8.0g                 Length (in.)
turn            int     %8.0g                 Turn Circle (ft.)
displacement    int     %8.0g                 Displacement (cu. in.)
gear_ratio      float   %6.2f                 Gear Ratio
foreign         byte    %8.0g      origin     Car type
----------------------------------------------------------------------------------------
Sorted by: foreign

. 
. set linesize 45

. summarize

    Variable |        Obs        Mean    Std.
>  Dev.       Min        Max
-------------+-------------------------------
> --------------------------
        make |          0
       price |         74    6165.257    2949
> .496       3291      15906
         mpg |         74     21.2973    5.78
> 5503         12         41
       rep78 |         69    3.405797    .989
> 9323          1          5
    headroom |         74    2.993243    .845
> 9948        1.5          5
-------------+-------------------------------
> --------------------------
       trunk |         74    13.75676    4.27
> 7404          5         23
      weight |         74    3019.459    777.
> 1936       1760       4840
      length |         74    187.9324    22.2
> 6634        142        233
        turn |         74    39.64865    4.39
> 9354         31         51
displacement |         74    197.2973    91.8
> 3722         79        425
-------------+-------------------------------
> --------------------------
  gear_ratio |         74    3.014865    .456
> 2871       2.19       3.89
     foreign |         74    .2972973    .460
> 1885          0          1