do html-reports.do capture file close con ! rm nicereport.html ! rm delete_me.html sysuse auto, clear recode mpg (min/25 = 0 "Low/Medium") (25/max = 1 "High"), generate(mpg2) label var mpg2 "Mileage (level)" local tabn 1 local fign 1 file open con using nicereport.html, text write replace html_start, no_h1 html_h, text("A nice HTML report") level(2) html_p, text("Fasten your seatbelts for a thrilling analysis of the auto.dta data.") // First we will give the mean MPG and median price quietly summarize mpg local mean_mpg: display %8.2f r(mean) quietly summarize price, detail local median_price = r(p50) html_p, text("The mean miles per gallon was `mean_mpg' and the median price was USD `median_price'.") // Now we'll get a table for two binary variables html_unitab foreign, caption("Country of manufacture") tableno(`tabn') local ++tabn html_unitab mpg2, caption("Miles per gallon") tableno(`tabn') local ++tabn // And we'll insert a graph histogram mpg graph export fig1.png, replace html_img, img_file("fig1.png") caption("Distribution of MPG") figureno(`fign') local ++fign html_h, text("Regression output") level(3) file close con /* Now let's include some logging - we get ht to make another file and the notag options make it just a snippet of HTML */ htopen using delete_me.html, notag htlog regress mpg price htclose, notag // then we can add it to nicereport.html using the tfinsert command file open con using nicereport.html, text write append tfinsert con using delete_me.html file close con webdoc do example3b.do