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: add column in -tabout- for symbols


From   Eric Booth <[email protected]>
To   "<[email protected]>" <[email protected]>
Subject   Re: st: add column in -tabout- for symbols
Date   Mon, 13 Jun 2011 12:47:13 +0000

<>
First, the the 2 example tables you provided appeared to be the same to me until I pasted them into a spreadsheet.  Only then could I tell that you had a tab instead of spaces between the row label and the symbols  -- these types of subtle formatting differences may not always translate well into an email/web based listserve, so you may want to describe the differences more carefully to get better responses  (esp. since these messages are susceptible to problems with wrapping, character encoding, etc that may garble formatting to begin with).

Usually in the standard or rb layouts in -tabout-, you can use the h3() option to exercise more control over the clab() contents (for instance, using a pipe "|" to push these symbols into new columns/rows); however, in row layout, I cannot get h3() to manipulate the the clab() down the rows .  
Others may know how to get -tabout- to do what you ask, but one kludge I can come up with is to preserve, re-insheet the tabout table as a dataset, manipulate the table, and then outsheet it and restore.  E.g., 

***********!
sysuse auto, clear
gen lengthc = length>200
tabout foreign lengthc using test_tabout.txt, ///
style(tab) cells(row freq) ///
format(1 0) ///
clab(% N) layout(row) 	///
dpcomma replace
type test_tabout.txt

preserve
insheet using test_tabout.txt, nonames clear
split v1
replace v12 = "N" if strpos(v1, "N")
replace v1 = "" if strpos(v1, "N")
replace v1 = subinstr(v1, "%", "", 1)
drop v11
order v1 v12

outsheet using "test_tabout_updated.txt", ///
	replace nonames noquote
restore

type test_tabout_updated.txt
***********!

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


On Jun 13, 2011, at 12:22 AM, Kaulisch, Marc wrote:

> Using -tabout- (from ssc) I encounter a difficulty I can not solve on my
> own. Using the layout(row) option I would like to add a column for the
> symbols (% and N).
> The following example should illustrate my point:
> sysuse auto
> gen lengthc = length>200
> tabout foreign lengthc using test_tabout.doc, style(tab) cells(row freq)
> format(1 0) ///
> 								clab(%
> N) layout(row) 			///
> 								dpcomma
> replace
> I get the following table
> 
> lengthc		  
> Car type	0	1	Total
> 		  
> Domestic %	55,8	44,2	100,0
> N       29	23	52
> Foreign %	100,0	0,0	100,0
> N       22	0	22
> Total % 68,9	31,1	100,0
> N       51	23	74
> 
> But I would like to get the following:
> lengthc		  
> Car type		0	1	Total
> 		  
> Domestic	 %	55,8	44,2	100,0
> 	N       29	23	52
> Foreign	 %	100,0	0,0	100,0
> 	N       22	0	22
> Total	 % 68,9	31,1	100,0
> 	N       51	23	74
> 
> Is there a way to add this column automatically in the program?
> 
> Thanks for your help.
> 
> 
> Marc
> 
> *
> *   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