Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: tabout column alignment


From   Eric Booth <ebooth@ppri.tamu.edu>
To   "<statalist@hsphsun2.harvard.edu>" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: tabout column alignment
Date   Tue, 26 Apr 2011 18:57:32 +0000

<>

Importing or copy/pasting this output into a spreadsheet or the Stata data editor will show that it is already aligned in the sense that there is a tab character already separating the columns.  If you want to force it to look better aligned in a text document, you can manually put in some extra tabs between the columns (I'm doubt -tabout- has that capability, nor would it be useful). 
If you are really sending -tabout- (from SSC, BTW) output to a text file, then it would only line up if the all the variable and value labels were roughly the same length, so something like this would line up better:
***
rename PRACTICE PRACT
tabout PRACT using aaa.txt, cell(freq col) ///
	format(0 1p) replace 
type aaa.txt
***
or, better, by suppressing the h3() and totals() labels:
***
tabout PRACT using aaa.txt, cell(freq col) ///
	format(0 1p) replace  ///
	h3(nil) total(" ") 
type aaa.txt
***
but I don't think either of these are useful. 

Instead, alignment should be considered with the target document in mind.  If you are talking about something like period alignment, that is accomplished in your target document/software. You can change the style() option to better format the table for your target document (csv, tab, html, tex, etc).  You can send the txt file directly to a spreadsheet by just changing the file extension to .xls and the style() to tab or csv, depending on taste. An example
***
clear
set obs 10
g PRACT = int(runiform()*10)
tabout PRACT using  aaa.xls, cell(freq col) ///
	format(0 1p) replace ///
	h3(nil) total(" ") style(tab)
***
then open in your spreadsheet program.  There are more options for precisely controlling format/alignment for output going to a tex document, but that is a completely different approach.

- Eric

__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
ebooth@ppri.tamu.edu



On Apr 26, 2011, at 1:25 PM, William Trick wrote:

> Hello,
> 
> I am exploring use of tabout rather than the copy and paste route for
> tabular output.
> 
> I have been exporting as text & the column alignment is off (see
> below); I have been unable to reformat the columns so that they align.
> 
> PRACTICE        No.     %
> No      92      100.0%
> Total   92      100.0%
> 
> tabout PRACTICE using aaa.txt, cell(freq col) format(0 1p) replace
> 
> Any suggestions?
> 
> Bill
> 
> *
> *   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index