Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: log only results of r-class commands


From   "Sergiy Radyakin" <[email protected]>
To   [email protected]
Subject   Re: st: log only results of r-class commands
Date   Thu, 22 May 2008 17:08:27 -0400

I am not sure that I understand exactly where the difficulty is, but
if any command places a matrix into an r()-result, it is possible to
output it to, say, Excel with -xml_tab-.

If you want to mechanically dump all the results of r-class commands,
then here is how:

1. create a program Protocol.ado in your ado directory

program define Protocol

  return clear // need this in case anything is not an r-class command
  quietly `0'

  di "Saved Results:"
  di `"`:r(matrices)'"'
  di `"`:r(scalars)'"'
  di `"`:r(macros)'"'
  di `"`:r(functions)'"'

  local matrixlist `"`:r(matrices)'"'

  // Here do whatever you want with the contents, e.g. list the matrices
  foreach m of local matrixlist {
    matrix list r(`m')
  }

end


2. Open a log file

3. instead of writing "sum x" write "Protocol sum x" everywhere in your program

4. Close the log file

Demo:

sysuse auto
log using C:\MyLogFile.txt, text
Protocol tabstat price length weight, save
log close


Hope this is what you were looking for.

Best regards,
  Sergiy




On 5/22/08, Dr. Stephen Rothenberg <[email protected]> wrote:
> I am setting up do-files in anticipation of running repetitive descriptive
> statistics for a long-term project.  I will need to produce appendices that
> contain these descriptive statistics, each of which will be scores of pages
> long.
>
> My problem is logging the output of commands like -sum- or -fsum- so I can
> print the appendix stats.  I'd like to produce output that contains only the
> results of the commands in legible tables and my preceding comments that
> identify them, without the tedious chore of editing out the commands
> themselves. The commands run to nearly 400 lines in scattered places
> throughout the log, despite using -bysort- to combine analyses.
>
> Stata includes such commands as -quietly- and the various -set output-
> variations, all of which suppress results output.  The user-supplied
> commands in the -estout- family and others do a great job in producing
> tables of estimation output.  They do not work with descriptive commands,
> which are r-class commands.  Stata allows me to open two logs
> simultaneously, one showing commands, comments, results, and error messages,
> the other showing only the commands, but not only results and comments.
>
> I've searched the FAQs, the ssc contributions, and Statalist, without
> success.
>
> Does anyone know:
> 1. A way to log only results of r-class commands in presentable tables?
> 2. If not, can someone provide a method that will do this?
> 3. If nothing now exists, will StataCorp consider making output only logging
> possible in future releases?
>
> Steve Rothenberg
> CINVESTAV-Merida
> Yucatan, Mexico
> *
> *   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/
>
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index