Bookmark and Share

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

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

Re: st: RE: How can I append tabout output in Excel using logout?

From   Neil Shephard <>
Subject   Re: st: RE: How can I append tabout output in Excel using logout?
Date   Wed, 28 Apr 2010 10:39:26 +0000

I don't really use Excel (other than to save data I've been sent to
CSV for importing into Stata) or use M$-Windows, but I suspect that
because of the proprietary nature of the Excel file format that
-logout- is actually writing CSV files and files with the .csv
extension are (generally) associated with the Excel program on most M$

If you _really_ want to do this (-collapse- and -statsby- will likely
get you there quicker though), then you can write lots of individual
files (with a slight tweaking of your code) and then concatenate them
into one large file.  You can even do this from within Stata by making
a shell call.

>> forv i=0/5 {
>> foreach y in male singlet{
>> forv s=0/1{
>> di "myga==`i' & `y'==`s'"
>> qui su bwtg if myga==`i' & intab1==1 & admit_ic==1 & bwtg<. & `y'
>>        if r(N)!=0{
>>  logout, save("C:\data\do_files\mytab_`i'_`y'_`s'.txt")  excel replace: tabstat
>> bwtg if myga==`i' & intab1==1 & admit_ic==1 & bwtg<., stat(n mean
>> median p25 p75 min max ) by(`y') col(stat) f(%9.0g) notot nosep
>> }
>> }
>> }
>> }

* Note that I've modified the above code so that each call to -logout-
is writing the results to an individual file based on levels of i, y
and s
* Under a UNIX-like system the command to use is 'cat' and whilst
you'd never have a "c:\" path the call would be
!cat c:/data/do_files/mytab_* > c:/data/do_files/mytab.txt

* Under M$-Windows you need to use the DOS Copy command (see
!COPY c:/data/do_files/mytab_* c:/data/do_files/mytab.txt

Should do the trick, but as Nick says what is it that you can't do in Stata?


"... no scientific worker has a fixed level of significance at which
from year to year, and in all circumstances, he rejects hypotheses; he
rather gives his mind to each particular case in the light of his
evidence and his ideas." - Sir Ronald A. Fisher (1956)

Email -
Website -
Photos -

*   For searches and help try:

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