Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: extract "describe" output/Variable window to Excel

From   Jacob Wegelin <>
Subject   st: extract "describe" output/Variable window to Excel
Date   Sun, 9 Oct 2005 11:58:53 -0700 (PDT)

Is there a way to do something like the following?

Export the contents of the Variable window, or better yet the
information yielded by the "describe" command, to a tab-delimited text file.

(Note that the contents of Review window can be easily extracted by
right-clicking that window, but that right-clicking the Variable window
does not permit the same operation.)

The idea is to get a spreadsheet with a row for each variable and with
at least the following two columns:

	the name of the variable

	explanation of	what the variable represents.

and ideally also the following columns:

	Storage type

	Display format

	Value label

My reason for wanting to export this information, rather than just looking
at it in the Results or Variable windows, is so that I can browse through
it, search in it (e.g., find all variables with "ffr" in their name),
and add other fields such as a column that simply numbers the variables

The following laborious, error-prone workaround approximates the above:

	Start a log file as junk.log (plain text).

	Type "describe" in the command window.

	Keep hitting the spacebar until all the variables have scrolled

	Stop the log.

	Open the log file in a text editor and delete the irrelevant
	lines at the top and bottom of the file.

	Further edit the file so that each variable's information appears on a single
	line (no wraparound).

	Open the file in excel, using the "fixed width" option.

By this procedure I was able to construct what I would call a codebook
(not to be confused from the Stata "codebook" output) in ten minutes or
so. Long variable names are truncated in the "describe" output, however
(for example, lumenperimeterlength becomes lumenperimete~h)
and the procedure seems unnecessarily tedious.  And the user could
inadvertently introduce errors, since the procedure is not fully

Is there a more automatic way to do this?

Thanks for any ideas


Jacob A. Wegelin
Assistant Adjunct Professor
Division of Biostatistics
Department of Public Health Sciences
School of Medicine
University of California, Davis
CRISP building
2921 Stockton Blvd Suite 1400
Sacramento CA 95817
jawegelin - at -
*   For searches and help try:

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