I've once asked that question and Nick Cox pointed me to matcell(M) option
and them "mat li M" which is copiable as text in Excel.
Another option is the "tabstat, long save" and the "tabstatmat" commands.
Hope this helps.
Amadou.
tab X Y, matcell(M)
or
tabstat X Y, c(...) long save
ret li
matrix M=r(Statot, r(Stat1, ...)
mat li M
"FEIVESON, ALAN H. (AL)
(JSC-SK) (NASA)" To: "'[email protected]'" <[email protected]>
<[email protected] cc:
> Subject: RE: st: tabulate results -> Excel
Sent by:
owner-statalist@hsphsun2.
harvard.edu
11/23/2004 02:42 PM
Please respond to
statalist
If you don't mind the headings getting messed up, you can use tabulate, then
select the table and use the "copy table" option.This will more ore less
paste correctly into excel.
al Feiveson
-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of Roger Newson
Sent: Tuesday, November 23, 2004 1:15 PM
To: [email protected]
Subject: Re: st: tabulate results -> Excel
At 17:00 23/11/2004, Kit Baum wrote:
>Posting for my colleague Peter Gottschalk:
>
>I have a bunch of crosstabs (from tabulate) that need to be turned into
>tables in an excel spreadsheet. Is there a way of outputing the contents
>of tabulate to a file?
>
A possibility is to use -xcontract-, downloadable from SSC, instead of
-tabulate-. If you type
tempfile tf1 tf2 tf3
xcontract y, saving(`tf1', replace) freq(rowfreq) percent(rowpct)
xcontract x, saving(`tf2', replace) freq(colfreq) percent(colpct)
xcontract x y, saving(`tf3', replace) freq(cellfreq) percent(cellpct)
use `tf3', clear
merge x using `tf2'
sort y x
merge y using `tf1'
sort x y
then you should have a dataset in memory with 1 observation per cell and
variables
x, y, rowfreq, rowpct, colfreq, colpct, cellfreq and cellpct, containing
the x-values and y-values and also the row, column and cell frequencies and
percents. This dataset can be further reprocessed using -reshape-, if Peter
wants a dataset with 1 observation per row instead of a dataset with 1
observation per cell. The final dataset can be output to a text spreadsheet
file using the official Stata command -outsheet-.
I hope this helps.
Best wishes
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]
Website: http://www.kcl-phs.org.uk/rogernewson
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/
*
* 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/
*
* 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/