Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Exporting tables to Excel - Resolved


From   "Michael C. Morrison" <[email protected]>
To   [email protected]
Subject   Re: st: Exporting tables to Excel - Resolved
Date   Fri, 04 Mar 2011 12:04:44 -0600

Writing the file to "c:\ado\myexcelfile.xls" works. I usually don't save any files to c:\ so I've never encountered this error before. Thanks for your assistance.

Mike



On 3/4/2011 11:24 AM, Eric Booth wrote:
<>

Sorry I should have asked you to run:    ls    "C:\ado\folder11\"
with just the path, not the name of the file included -- this doesn't help us much here since  "C:\" probably exists.

This error still stems from the problem that you cannot (probably because you don't have permissions ) save this file to "C:\".  I just ran your exact same code on a colleague's Windows XP Server 2003 machine (I use Mac OSX) and I got the same error you did because permissions to write files directly to "C:\" is restricted on his machine, but when I changed the path to his "mydocuments" folder or "C:\ado\" it ran just fine.    Assuming your present working directory (type -pwd- to check this)  is not "C:\", you could also try just saving your file without specifying the path.

- Eric

__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754


On Mar 4, 2011, at 11:08 AM, Michael Morrison wrote:

Ok, here's the code I ran:

sysuse auto, clear
tabout for rep78 trunk  using "c:\myexcelfile.txt", sum replace   ///
c(mean mpg N mpg mean price N price median turn median headr N weight) ///
f(1c) ptotal(both)

Here's the error I get:

File c:\myexcelfile.txt
is already open inside another application.
Please close it before running tabout.

Here's the result of running -Is-

. ls  "c:\myexcelfile.txt"
file not found

Thanks for your help.

Mike


On 3/4/2011 10:28 AM, Eric Booth wrote:
<>

   Once again, when you hit an error, send us the code you ran that created the error.
Assuming you are correct that no application has myexcelfile.txt (or.xls) open and your permissions are all correct, then another option is that you misspecified the path for 'using'.
So you may have typed "C:\ado\folder11\myexcelfile.txt" and "folder11" doesn't exist (or you missed a space, etc.).  Usually when I get this same error from -tabout-, it's because the using path is wrong.
Try listing the other files in that path to make sure Stata can navigate there, type:

  ls  "<insert your file path here>"
so for my example above, type
ls    "C:\ado\folder11\myexcelfile.txt"

(and report what happens)

- Eric

__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]


On Mar 4, 2011, at 10:10 AM, Michael Morrison wrote:


I just tried the generous example provided by Eric but I got this error message:

"File myexcelfile.txt
is already open inside another application.
Please close it before running tabout."

The problem is that there's no other program using myexcelfile.txt

I suspect this has something to do with administrator privileges, but I'm not sure. I did a -hsearch administrator- and received a few hits but nothing specific to see if I was on the right path.

Any help would be appreciated.

Mike


On 3/4/2011 8:28 AM, Eric Booth wrote:

<>

-tabout- (from SSC) will allow you to put many variables in the c() option and varlist.
Did you specify the 'sum' option as well? Also, keep in mind that the 'n' stat you specified should be 'N'.
  Let us know the -tabout- code you tried that isn't working.

This example exports an excel table (really just a text file that excel will open since I gave it a xls extension) with some summary stats (N, mean, median) for 3 variables by 5 other variables.
***************!
sysuse auto, clear
tabout for rep78 trunk  using "myexcelfile.xls", sum replace   ///
c(mean mpg N mpg mean price N price median turn median headr N weight) ///
f(1c) ptotal(both)
***************!
Take a look at this for some help with -tabout-:  http://fmwww.bc.edu/repec/bocode/t/tabout_tutorial.pdf

There are lots of other options out there besides -tabout- (though it's the one I most commonly use).   Try typing -findit export table-  into the command line to see some other user packages that have similar functionality.

- Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754

On Mar 4, 2011, at 7:58 AM, Diana Iancu wrote:



Dear all,

Is it possible to export complicated tables from Stata to Excel, for instance:
table var1 var2, c(n var3 mean var3) ?
I have tried tabout, but as far as I can see, it doesn't allow me to include more than one variable in c( ) or to table 3 variables.
Your assistance will be highly appreciated.

Best regards,
Diana Iancu



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index