I have an ado that uses the file command to convert a Stata dataset to an
HTML table. To improve the performance of the program, I want to have it
loop through the rows and execute a single command to write out each row.
To do this, I first go through the varlist and build a macro that says how
the rows should be written, e.g.,
<TR><TD> %8.2f (var1[`i']) </TD><TD> %5s (var2[`i']) </TD></TR>
The problem I am encountering involves building a macro that contains an
untranslated macro. I have been able to get the program to work by
replacing `i' above with RoWNuM and having a line that reads
local writeme : subinstr local writestring "RoWNuM" "`i'"
then have a
file write x `writeme' _newline
but that means an extra command has to get executed for each row of data,
something that I'm sure compromises the efficiency of the code. Still, the
subinstr method above is 1/3 faster than looping through the varlist for
each row of data.
Is there a way to have writestring contain `i'?
*
* 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/