After many years of resistance, I am trying my hand
at generating attractive reports directly from Stata
via SMCL. I have run into a quietly/noisily problem.
The general idea is that I have to create a massive
set of tables of variables that are one of several
types. I can trap their type, and then depending on
their type I call a program which takes an integer
argument to determine if the table will run off the
page; if so, I want to insert a {newpage} first, and
reset the line counter accordingly.
program checkend
args linenum
if $line+`linenum'>$pagelength {
log on mylog
noi di "{newpage}"
noi di "`header'"
log off mylog
global line=1 /* one line for the header */
}
global line=$line+`linenum'
end
quietly {
foreach var in hugevarlist {
gettype `var' /* trust me, this works */
if `type'=="S" {
noi checkend 3
log on mylog
noi print the output
log off mylog
}
if `type'=="C" {
levelsof `var'
local nvals =r(nvals) /* modified -levelsof-*/
local chk=`nvals'+1
noi checkend `chk'
log on mylog
noi print the output
log off mylog
}
}
}
The problem is that the program -checkend- is NOT producing
any output.
When I take the contents of the program and paste it into
each location, everything works fine. However, there are 10
different types of variables, and when I fiddle with the font
and header, I have to go back through and edit each one. It
will be much better if I can keep it in a program.
I CAN get -checkend- to produce output by using
noi di as smcl "{newpage}"
but then what I get isn't smcl, and the postscript translator
produces something that is broken (ie, can't be translated to
PDF). Moreover, the log file is defined as SMCL, so this seems
superfluous.
I'm thinking the problem may be that the log file -mylog- isn't
passing to the program? I have to use a named log file because
I need a second log file open to track some other output for
each variable.
Otherwise, it must be that I'm not using quietly noisily
correctly, but I thought
quietly noi myprog
would let -myprog- output whatever it wanted to.
Thoughts?
Jeph
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/