Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
sara khan <sarakhanum84@googlemail.com> |

To |
statalist@hsphsun2.harvard.edu |

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

Date |
Wed, 28 Apr 2010 13:13:31 +0100 |

Thank you all for responses. I find formatting tables easier to do in Excel. Roy Wada, the author of -logout- offered the following solution, which worked for me: * drop frivolous rows sysuse auto, clear local append replace foreach y in trunk weight { forv s=0/1 { qui su mpg if foreign==`s' if r(N)!=0{ caplog using logfile, `append': tabstat mpg if foreign==`s' , stat(n mean median p25 p75 min max ) local append append } } } logout, clear use(logfile) drop if t1=="variable" & _n~=1 logout, save(test_together) excel replace * keep them sysuse auto, clear local append replace foreach y in trunk weight { forv s=0/1 { qui su mpg if foreign==`s' if r(N)!=0{ caplog using logfile, `append': tabstat mpg if foreign==`s' , stat(n mean median p25 p75 min max ) local append append } } } logout, use(logfile) save(test_together) excel replace On Wed, Apr 28, 2010 at 11:39 AM, Neil Shephard <nshephard@gmail.com> wrote: > 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$ > machines. > > 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 > http://support.microsoft.com/kb/69575) > !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? > > > Neil > > -- > "... 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 - nshephard@gmail.com > Website - http://slack.ser.man.ac.uk/ > Photos - http://www.flickr.com/photos/slackline/ > > * > * 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/

**Follow-Ups**:**RE: st: RE: How can I append tabout output in Excel using logout?***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**st: How can I append tabout output in Excel using logout?***From:*sara khan <sarakhanum84@googlemail.com>

**st: RE: How can I append tabout output in Excel using logout?***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**Re: st: RE: How can I append tabout output in Excel using logout?***From:*sara khan <sarakhanum84@googlemail.com>

**Re: st: RE: How can I append tabout output in Excel using logout?***From:*Neil Shephard <nshephard@gmail.com>

- Prev by Date:
**Re: st: RE: How can I append tabout output in Excel using logout?** - Next by Date:
**re: Re: st: Overriding a loop if 0 observations using tabstat** - Previous by thread:
**Re: st: RE: How can I append tabout output in Excel using logout?** - Next by thread:
**RE: st: RE: How can I append tabout output in Excel using logout?** - Index(es):