UCLA Stat Computing Portal Web
Tools
ATS Stat
Computing
 

Making Your Stata Program Ready for stata2htm

These notes show how to make your Stata program ready for running through the tool stata2htm that ATS has developed to make it easy to convert a SAS program into a web page.  We assume you have downloaded stata2htm.

It is probably easiest to show how to prepare your program by using an example.  This is the program sample.do that creates sample.log .

Sample Program

set more off
capture log close
log using sample.log , replace

*T Page Title 

*H Heading for First Section 

* This module will show how to read a small
* raw data file within a Stata program.
* Consider the sample program below. 

clear
input str3 make mpg rep78 weight foreign 
AMC 22 3 2930 0
AMC 17 3 3350 0
AMC 22 . 2640 0
end

* We can use the list command to see that the data was 
* read properly.
list

*H Heading for Second Section 

* Now that we have read the data, let's do some
* summary statistics.
summarize

* and lets tabulate mpg
tab mpg

log close

Web page created from sample progrm

The program sample.do is run in Stata by typing

do sample

and this creates sample.log.  You can then run, from the Command Prompt

stata2htm sample 

creating the web page sample.htm .

Explanation of sample program