Output on the screen

All Stata output is displayed, not surprisingly, in the output window (which is called Results window by Stata Corp). 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.

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


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

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.

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: 25 May 2017