[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: tabulate results -> Excel
At 17:00 23/11/2004, Kit Baum wrote:
Posting for my colleague Peter Gottschalk:
A possibility is to use -xcontract-, downloadable from SSC, instead of
-tabulate-. If you type
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?
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
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.
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
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
Opinions expressed are those of the author, not the institution.
* For searches and help try: