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

st: RE: Output tables from -table- command to Excel


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Output tables from -table- command to Excel
Date   Wed, 9 Jul 2003 19:32:30 +0100

[email protected]

> I am working with a dataset containing approx. 5400 
> observations and I was able to extract the information I needed 
> via the -table- command, in specifically,
> -table countyname admt_mnth admt_yr, contents(freq) concise- 
> and for the second (and more cumbersome extraction)
> -table countyname admt_wk admt_mnth if admt_mnth==9 & 
> admt_yr==1991, contents(freq) concise-
> where the -if- statement was changed repeatedly until I reached 
> month 12 and year 2001 (otherwise, the output was too difficult 
> to read since admt_wk allows for 52 possible values).  I 
> printed the output via creation of a log file and saving it 
> with a .smcl extension (which prints nicely, btw), however, I 
> need to create rates using a different population and thus 
> would like to output the tables to an Excel file (because 
> manual input wants to be avoided) where the counties would be 
> listed down the rows and the weeks (all 52) listed across the 
> top with the corresponding number of cases in each cell.  I 
> read the Statalist email from 20 June regarding 'exporting 
> tables' but I am unable to follow what they suggest or my 
> objective differs from theirs.  Can anyone provide insight or 
> another method more amenable to my objective (e.g. creation of 
> new variables altogether)?

I understand that you want a fairly wide table, 

rows    counties 
cols    weeks 
cells   frequencies, 

exported to Excel (not clear on why the latter). 

I am not sure that -table- is your best bet. 
I would try more rudimentary approach 

preserve 
contract county week 
reshape wide _freq, i(county) j(week) 
outsheet using toexcel
restore 

Nick 
[email protected] 
*
*   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