------------------------------------------------------------------------------- help for do2htm -------------------------------------------------------------------------------Make results of a .do file into an HTML file
do2htm dofile [, replace title(string) input(string) result(string) bg(string{cmd:) ats ]
Description
do2htm runs your do file and saves the results as a .smcl file which is converted to an HTML file using a modified version of log2html (originally written by, and thanks to, Christopher F Baum and Nicholas J. Cox, search log2html to obtain that program). If your file contains commands that create graphs, you can preface these commands with grss (see help grss) and when the .do file is run the graphs will be stored as .png files and the .htm file will show the graphs after the graph command. This creates one continuous output file with your commands, output and graphs, all viewable within a web browser.
do2htm requires only the base name of the dofile: e.g. my, if the .do file is named my.do. The name of the HTML file produced will be this base name with .htm appended, e.g. my.htm.
do2htm requires Stata version 8 at least, born on April 10, 2003 or later.
Options
replace specifies that if the HTML file exists, it is to be replaced.
title() specifies a string to be placed in the <TITLE> of the HTML page, and on the first line of the body of the page, using a <H2> heading.
The remaining options pertain to color choices. By default, do2htm produces a complete HTML page (i.e. with <HTML> and <BODY> tags) with a white background. Input lines (those resulting from user input) are rendered in RGB color "CC6600" (a shade of brown) and highlighted result-window lines are rendered in RGB color "000099" (a shade of blue). The options permit other choices for these three colors. For best results, one of the 216 "web safe" colors that display properly in web browsers on all computers in 256-color mode should be used. Also note that some combinations of colors are not workable; e.g. a black ("000000") background will cause all normally-rendered text to disappear.
input() allows the specification of a different color for the user input lines, in standard RGB notation (three duples of two bytes, each 00-FF).
result() allows the specification of a different color for the highlighted result lines, in standard RGB notation.
bg() allows the specification of a different color for the background, in standard RGB notation. For convenience, the argument may be given as "gray" or "grey", approximating most browsers' default behavior.
ats specifies that all output will be black, with commands that are bold. Also comments that start with two stars (**) are indented and presented in the default browser font, e.g. times roman, with consecutive comments running together to appear as a single paragraph. This option is named ats since it resembles the style of the ATS web pages.
Examples
See accompanying file do2htmtest.do, also repeated below these examples
. do2htm do2htmtest, replace
. do2htm do2htmtest, replace ti("Automobile study")
. do2htm do2htmtest, replace in(ff3300) res(003333) bg(grey)
. do2htm do2htmtest, replace plain
Example do file, do2htmtest.do
clear
use https://stats.idre.ucla.edu/stat/stata/notes/hsb2
* show summarize command summarize
* a long graph command with wide space in the comment * and a very long command * Notice we start with "grss" so this graph will show up in the .htm file grss graph twoway (scatter read write, ylabel(0 5 to 100) xlabel(10 20 to 90) ) > (lfit read write, ylabel(0 5 to 100) xlabel(10 20 to 90))
** this is ** two comments ** and commands spanning over multiple lines ** Notice we start with "grss" so this graph will show up in the .htm file grss scatter /// read /// write /// math
* a short comment * A comment on the describe command that really goes on way too long and really > is very wide and long describe
* and now we make a scatterplot * but we forgot the "grss" prefix, so this does NOT show up in the * web page scatter science socst
** a comment on tab starting with two stars tab ses
Reference
Priester, Gary W. 2000. All you need to know about web safe colors. http://www.webdevelopersjournal.com/articles/websafe1/websafe_colors.html
Acknowledgements
We acknowledge the authors of log2html Christopher F Baum, Boston College, and Nicholas J. Cox, University of Durham, on which most of this program is based. However, we are responsible for errors resulting from our modification of their program.
Author
Statistical Consulting Group Institute for Digital Research and Education, UCLA idrestat@ucla.edu
Also see
Manual: [R] log, [P] smcl
On-line: help for log, smcl, grss, log2html