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

RE: st: tabulate results -> Excel


From   "FEIVESON, ALAN H. (AL) (JSC-SK) (NASA)" <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: tabulate results -> Excel
Date   Tue, 23 Nov 2004 13:42:45 -0600

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/



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