ncdcta00,
in addition to Maarten's post, I do not think there is any command
available that will produce an excel table in the Microsoft
proprietary fileformat with the ending xls. So, as suggested by
Maarten, copying is one way to go. Please note that a simple "copy"
will get you scrambled cell content in excel. You should mark the
output table produced by -summarize- in the Stata results window and
right-click with your mouse there and then choose "Copy Table". One
more hint, make sure that Stata uses the same decimal character (comma
or period) as Microsoft Excel does. Otherwise you will get nonsense
output in Excel, eg, depending on your regional settings a 1.023 (one
point zero two three) from your Stata results window could become a
1.023 (one-thousand-and-twenty-three) in you Excel sheet. However, I
would consider the copy&paste approach only useful for if you a want
to create a few tables.
I would suggest another solution: create a "resultsset" and use
-outsheet- to export it to a csv-file which then can be imported into
excel. You could use the following do-file code, just copy it and
paste it into the dofile-editor window:
/* start here */
set more off
// load some example dataset...
sysuse auto, clear
// Store required statistics in a local macro
// so you can use them later to name you variables
local statistics N mean sd min max
// Issue the command that will show the table with summary statistics
// plus: it will save all of that to a return value
tabstat price length weight, stats(`statistics') save
// drop all observations + variables
drop _all
// store content of matrix returned by -tabstat- in a matrix named dummy
mat dummy=r(StatTotal)
// take dummy and store its columns as new variables
svmat dummy, names(col)
// transpose the "resultsset" so variables become observations
// and vice versa. Former variable names will be stored in the new
// variable "_varname"
xpose, clear varname
// tokenize the local macro statistics so...
tokenize `statistics'
// run a loop over all elements in statistics
// number of elements is dynamically determined
forval i=1/`: list sizeof statistics' {
ren v`i' ``i''
}
// rename variable "_varname" to "source_var"
ren _varname source_var
// change variable order so that source_var appears first
order source_var
// "export" the "resultsset" to a comma separated values - file named
// "var_summary.csv
outsheet using var_summary.csv, comma replace
/*
the file var_summary.csv than has to be imported
into MS Excel.
*/
/* end here */
On 1/22/07, Maarten Buis <[email protected]> wrote:
You could copy the output as a table and paste it in excel.
Hope this helps,
Maarten
-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands
visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434
+31 20 5986715
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of [email protected]
Sent: maandag 22 januari 2007 16:26
To: [email protected]
Subject: st: table for sum
Hi,
I want to ask you if exist a command for make an excel table after
the command sum
thanks
*
* 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/