Output

Output on the screen

All numerical and verbal Stata output is displayed, not surprisingly, in the output window (which is called Results window by the Stata people). Here's a few helpful remarks:

  • Remember the set more off command if repeatedly pressing keys to make Stata move on annoys you.
  • If you have wide tables or similar output, try set linesize 132 or whatever you like to avoid tables being wrapped around.
  • You can scroll back in the output window, but the number of lines that can be retrieved is limited. set scrollbufsize 50000 (using any number you prefer) will allow you to scroll further up in the output window. Note that this command will take effect upon the next relaunch of Stata.

Note that graphs are displayed in window that are separate from the numerical output. See the entry on naming and saving graphs.

Formatting output

Results of regression models are typically displayed with six or seven decimal places. This may be precisely what you want, but normally you should strive for focussing on the relevant information, which ideally would be in the range of two to four decimals. The command

set cformat %7.4f

will restrict coefficients, standard errors and confidence interval limits to four decimals.

Also available are commands for changing the display of the p-value and of the test statistics (t-values, z-values and the like); the commands are set pformat and set sformat, respectively. Note that the maximum format widths for cformat, pformat, and sformat are 9, 5, and 8 (in that order). Therefore, you may encounter difficulties if you wish to display are larger number of decimals than the one set by default. But you should strive for simplicity anyway.

Log files, or saving output

To keep record of Stata's output, you have to specify a log file. In other words, by default the output is shown in the output window only. Note that you have to open the log file before output can be written to it. In other words, you cannot save output to a log file a posteriori. (Note, however, that there is some sort of workaround; see the following section.)

There are two formats for the log file, the SMCL format (a specific Stata format, as far as I know) and the text or plain ASCII format. Stata recommends to use the SMCL format, as it keeps some formatting that is helpful when looking at the file with the Stata viewer; it is therefore the default format. If you are sure you do not need this, the text format is better for accessing the log file with other software such as a word processor. However, you can also "translate" an SMCL file into a text file.

log using session20090213

causes Stata to write your commands and Stata's results into file session20090213.smcl, that is, a file in SMCL format.

log using session20090213.log

causes Stata to write your commands and Stata's results into file session20090213.log, which will be in text or plain ASCII format.

The file will be found in your working directory. If you have started Stata from the desktop, the default is a directory named \data. But you may have changed to a different directory; in this case you will find the log file there. You probably may also indicate a path for the log file.

Once you have opened a log file, you may temporarily suspend the output being written to it by

log off

Not surprisingly, to have further output written to the log file you have to switch

log on

A different thing is to close a log file with

log close

To have further output written to a log file, you have to specify again a log file with "log using....". It is important to know whether this file already exists and how you wish to handle this.

log using session20090213, replace

will overwrite the old file and start anew.

log using session20090213, append

will append the new output to the already existing file.

The results may either printed or opened with a word processor. For the latter purpose, the output has to be translated if you have used the SMCL format:

translate session20090213.smcl session20090213.log

Finally,

view session20090213

will open the Stata viewer and display the log file named session20090213.

What if I have forgotten to open a log file?

First, you can always copy the output directly from the screen to some other file, e.g., in a text processor.

Second, there is a nice feat which permits to save your results, as long as they are accessible in the results windows. It goes like this:

translate @Results "name-of-some-file.txt"

Now, Stata will write everything that can be found in the scroll buffer (equivalent to everything you can see on your screen, including those parts you have to scroll in order to see them) in a txt-File with the name "name-of-some-file". I.e., this file will not be in Stata format, but as the txt-File is universally accessible, there is nothing to worry about this.

More on logfiles

You may open several log files (up to five in SMCL and in text format, respectively). If I have found out how to do this (which I will do when I think I need several log files), I will tell you.

You may set the default log file type via "set logtype". With

set logtype t

("t" may be replaced by "text"), the default will be the text format. With

set logtype s

("s" may be replaced by "smcl"), the default will be the scml format again.

set logtype t, perm

will induce Stata to remember this setting the next time it is started.

Output in other formats

Special procedures for reliable (and dynamic) reporting available as of Stata 16!

As yet, I have not been able to cover this. Please have a look at the pertinent Stata webpage!

Other formats, particularly LaTeX

A number of user-written packages are available for translating Stata output into other formats, such as LaTeX, HTML or Word. I'm afraid there is no "one size fits all" solution. So, you might try one or several of the packages listed below. You have first to obtain these packages via findit name-of-package [e.g., findit outtex]; afterwards, you can get information via help name-of-package. Most of these are, as you may guess, for LaTeX.

latab produces a LaTeX-usable output for tables, but in the case of a simple frequency table, you cannot obtain cumulated percentages. With a crosstabulation, you can generate either counts or colum percentages or row percentages, but not two or three of these in one table.
latabstat produces a LaTeX file for the output of procedure tabstat.
tabout is quite complex; there is a tutorial, but be prepared to spend some time reading it. Vital information, such as required additions to the LaTeX preamble, comes near the end! Still, as yet I was not able to make the examples from the tutorial work on my LaTeX system. Will also produce output for HTML and Word.
maketex is very simple, but it does not help much, as it just takes your piece of output as it is and puts a LaTeX preamble at the beginning and the \end document command at the end of the file.
outtex, outreg2, est2tex, estout basically for output from estimation procedures.
corrtex for correlations.
graph2tex creates an .eps file from the most recent graph plus some LaTeX code to embed the graph into your Latex file.
sutex for summary statistics.
outtable despite appearances, it is not for tables, but for matrices.

Brief explanations of some of these packages may be found in Florent Bresson's Outils Stata pour LaTeX.

A brief note on HTML

Actually, for HTML output you do not really need a package, because probably the best solution, barring really complex formatting stuff, is simply to copy Stata tables as text file in raw ASCII into your HTML file and enclose it by the pre tag. This will reproduce the table in a monospace font, leaving intact all the blanks, whereas normally in HTML a series of blanks is reduced to a single blank.

Nevertheless, there is a package which may be downloaded via

net install http://www.stata-journal.com/software/sj12-4/dm0066.pkg

This packages allows you to open a HTLM file (with htopen), sending output to this file (via preceding any Stata command with htlog), sending text of your choice to this file (with htput), and some other stuff. See help htopen, which will open a help file for these and related subpackages.

Display of stored results

This section has been moved to the entry about access to Stata's results.

© W. Ludwig-Mayerhofer, Stata Guide | Last update: 30 Mar 2024