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 <[email protected]>
To   [email protected]
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
consecutively.

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
	past.

	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
automated.

Is there a more automatic way to do this?

Thanks for any ideas

Jake

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
U.S.A.
http://wegelin.ucdavis.edu/
jawegelin - at - ucdavis.edu
*
*   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