Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: log2html smcl formatting TOC


From   Eric Booth <[email protected]>
To   "<[email protected]>" <[email protected]>
Subject   Re: st: log2html smcl formatting TOC
Date   Wed, 10 Aug 2011 16:24:13 +0000

<>

I used to try to create these types of documents in html, patching together documents using various user-written programs from SSC (type -findit html-) and -file write-.  I've since abandoned that process, first for -rtfutil- (from SSC) and now I use various user-written commands produce LaTeX documents (mostly -texdoc-, -outreg-, -tabout-, and -texsave-).  There's a learning curve for producing documents with -rtfutil- or producing LaTeX documents, but if you really want to create custom documents and document elements, one of these may be your best option.

A kludge solution for inserting the html elements you want into your document might be to use -file write- along with the user-written program -appendfile- (from SSC) to build your document additions.  That is, you can write small html documents that you can append to the top or bottom of your html log file.   You would have to break up your html log file into sections if you wanted to insert any text in the body of the document using this method.

While -log2html- already writes the html header/body/etc tags, it always worked for me to just redefine those when I write files to append to the top or bottom of the html log file.

 Here's an example of how you might do it (watch for line wrapping below):

****************************************************************
cap log close
log using sysdirvars, replace

sysuse dir
local allfiles "`r(files)'"
foreach f of local allfiles {
sysuse "`f'", clear
di _newline "{title:`f'}"
di "{title:Variable list}"
descsave, list(name varlab, clean noobs)
}

log close
log2html sysdirvars, replace title(Variables in Example Files)


**add to top:
cap   file close handle1
file open handle1 using sysdirvarsbegin.html, write text replace
file write handle1 "<html>"  _n
file write handle1  "<head>"  _n
file write handle1 `"<font face="verdana" color="green"> HERE IS SOME FORMATTED TEXT  FOR A TOC </font>"' _n _n
file close handle1


**add to bottom:
cap   file close handle
file open handle using sysdirvarsend.html, write text replace
file write handle "<b> HERE IS SOME MORE TEXT</b>" _n
file write handle "</html>"
file close handle

**get appendfile from SSC:
appendfile  sysdirvarsend.html  sysdirvars.html 
appendfile    sysdirvars.html  sysdirvarsbegin.html

type sysdirvarsbegin.html   // -- sysdirvarsbegin.html is your appended doc
****************************************************************

- Eric


On Aug 10, 2011, at 10:37 AM, Nick Cox wrote:

> -log2html- is a user-written program from SSC. Please remember to
> specify where user-written programs you refer come from.
> 
> In both cases, I think you may need to do your own programming. The
> purpose of -log2html- is only to convert to HTML with modest
> formatting changes on the side. Its possibilities are limited to what
> is documented. Or, you want something more like -outreg- (SSC), I
> guess.
> 
> Nick
> 
> On Wed, Aug 10, 2011 at 3:41 PM, Jakob Petersen <[email protected]> wrote:
> 
>> I would like to produce summary statistics for a batch of files.
>> I am using log and log2html to format the results and have a couple of
>> questions;
>> 
>> ****************************************************************
>> cap log close
>> log using sysdirvars,replace
>> 
>> sysuse dir
>> local allfiles "`r(files)'"
>> foreach f of local allfiles {
>> sysuse "`f'", clear
>> di _newline "{title:`f'}"
>> di "{title:Variable list}"
>> descsave, list(name varlab, clean noobs)
>> }
>> 
>> log close
>> log2html sysdirvars, replace title(Variables in Example Files)
>> ****************************************************************
>> 
>> 1. Is it possible to suppress [input] from being printed in the log file
>> (other than by changing the colour to white)?
>> 2. Is it possible to format the headers in this example such that they could
>> be used when creating a table of contents in a word processor (heading 1,
>> heading 2, etc.)?
>> 
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index