At 09:44 13/09/02 -0400, Guillermo Cruces wrote:
Hello statlist,
I was wondering if there is a program in Stata to output the content of a
table
into tab or comma separated values (so that it can be open automatically by
Excel or other spreadsheet programs). "outreg" is amazing, but as far as I
know
it only works with regression output. "outtable" is great too, but it only
converts matrices (and only to Tex).
the "Copy table" option works perfectly, but it is not really convenient
for a)
Large tables, b) Large number of tables.
if not available, I could try to write one.
The -outsheet- command creates a generic tab-separated or comma-separated
spreadsheet, with rows corresponding to the observations of the current
data set and columns corresponding to the variables of the current data
set. Therefore, what Guillermo wants to do is probably best done as a
two-step process, where you first create a Stata data set with observations
corresponding to the rows of the table and variables corresponding to the
columns of the table, and then -outsheet- that data set to a generic
spreadsheet.
Guillermo doesn't state precisely what kind of table he wants to output.
However, there are many tools in official and unofficial Stata which might
be used to create a Stata data set for output to a generic spreadsheet
using -outsheet-. The -collapse- and -contract- commands are used to create
a Stata data set with 1 observation per by-group and data on frequencies
and summary statistics for that by-group. The -parmest- package
(downloadable from SSC) creates a Stata data set containing regression
output, with 1 observation per parameter of the regression model, or 1
observation per parameter per by-group, and data on confidence intervals,
P-values and other parameter attributes. The -reshape- command reshapes
data sets, and is useful if you want to convert a table with 1 confidence
interval per row to a data set with multiple confidence intervals per row.
I suspect that what Guillermo really wants to do is to output a table of
the kind produced by -tabulate-. The way forward is probably to write a
Stata program which produces an output data set with 1 observation per
table cell and data including cell frequencies, cell percentages, row
percentages and column percentages, and then to use -reshape- to re-arrange
the cells into rows. I might write the required program when I have the
time, unless Guillermo writes it and saves me the trouble.
I hope this helps.
Roger
--
Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom
Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
or 020 7848 6605 International +44 20 7848 6605
Email: [email protected]
Opinions expressed are those of the author, not the institution.
*
* 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/