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: tabout & Stata variable labels


From   Andrea Bennett <[email protected]>
To   [email protected]
Subject   Re: st: tabout & Stata variable labels
Date   Thu, 19 Aug 2010 20:03:48 +0200

Dear Eric,

The problem is solved! Many thanks!

Andrea

On Aug 19, 2010, at 17:53 , Eric Booth wrote:

> <>
> 
> I assume you're talking about the variable names in the col headers for the summary (mean) tables. 
> If so, the same principle applies--you want to use the h2() and h3() options to add/remove column headers.  So, if you don't want the variable names just the labels, but you want to keep the type of summary (mean), you can use the first example below.  If you want to get rid of the summary type (mean) AND the variable names and just keep the variable labels, use the second example below (for latex: substitute the "|" for "&" and changing the style to tex):
> 
> *********!
> sysuse auto, clear
> label li
> 
> **2.  variable labels in summary tables**
> 
> //ex1//
> tabout for rep78 using "test.xls", replace  c(mean mpg mean price mean weight)   ///
> bt font(bold) sum ptotal(single) lines(double)  h3(| `:var l mpg' | `:var l price' | `:var l weight'| ) 
> 
> //ex2//
> 	**use a h2() with blank spacers "|"  to get rid of var names & summary type(mean)
> tabout for rep78 using "test.xls", append  c(mean mpg mean price mean weight)   ///
> bt font(bold) sum ptotal(single) lines(double)  h3(| `:var l mpg' | `:var l price' | `:var l weight'| ) h2(| | | |)
> 
> 
> 	**this works for *ex2* too, it just moves the variable labels up one row to the h2 position:
> tabout for rep78 using "test.xls", append  c(mean mpg mean price mean weight)   ///
> bt font(bold) sum ptotal(single) lines(double)  h2(| `:var l mpg' | `:var l price' | `:var l weight'| ) h3(| | | |)
> **********!
> 
> Eric
> 
> __
> Eric A. Booth
> Public Policy Research Institute
> Texas A&M University
> [email protected]
> Office: +979.845.6754
> 
> On Aug 19, 2010, at 10:35 AM, Andrea Bennett wrote:
> 
>> Dear Eric,
>> 
>> This helped a lot! With LaTeX, on just has to make sure that the "|" are substituted by ""&"".
>> 
>> One problem however persists: The variable *labels* are correctly inserted into the .tex file, however the variable *names* are also there and I couldn't find any option to delete them automatically, i.e. having the variable labels only.
>> 
>> If anyone knows a work around, please let me know.
>> 
>> Kind regards,
>> 
>> Andrea
>> 
>> 
>> On Aug 17, 2010, at 21:16 , Eric Booth wrote:
>> 
>>> <>
>>> 
>>> You can use the h2() or h3() option to reference the value labels with a macro extended_fcn.
>>> You can use the extended function `:var l <varname>' to reference the variable label  and the 
>>> extended function `:val l <valuelabelname> <#>' to reference the value label for a category.
>>> 
>>> Im not a latex user, so here's an example that will open in a text editor or excel:
>>> 
>>> **********!
>>> sysuse auto, clear
>>> label li
>>> 
>>> **1.  value and variable labels in tabulations**
>>> tabout mpg for using "test.xls" , replace  ///
>>> h2(| "overwrite labels" | "overwrite2" | Total) ///
>>> h1("title here for `:var l mpg' by `:var l for'")
>>> 
>>> tabout mpg for using "test.xls" , append  ///
>>> h2(| `"`:label `:val l foreign' 0' "' | `"`:label `:val l foreign' 1'"' | Total)  ///
>>> h1("title here for `:var l mpg' by `:var l for'")
>>> 
>>> **2.  variable labels in summary tables**
>>> tabout for rep78 using "test.xls", append  c(mean mpg mean price mean weight)   ///
>>> bt font(bold) sum ptotal(single)  h2(| `:var l mpg' | `:var l price' | `:var l weight'| )
>>> 
>>> **********!
>>> 
>>> ~ Eric
>>> __
>>> Eric A. Booth
>>> Public Policy Research Institute
>>> Texas A&M University
>>> [email protected]
>>> Office: +979.845.6754
>>> 
>>> On Aug 17, 2010, at 1:37 PM, Andrea Bennett wrote:
>>> 
>>>> Dear Statalisters,
>>>> 
>>>> Is it really the case that -tabout- does not take into account the variable labels when generating a LaTeX table? I use the following command: -tabout sex language using example.tex, c(mean age mean dispincome mean grademath) replace style(tex) bt font(bold) sum ptotal(single) topstr(15cm) topf(top.tex) botf(bot.tex) botstr(Just a test.)-. Yet, although -tabout- uses "Female" & "Male" as well as "English speaking" & "Other language" for the vertical variables (it uses the value labels), it sticks to the variable names for the horizontal output. I've browsed the web and checked the handout but really could not find any option to make -tabout- show my variable labels. I simply would like to automatically show "Disposable income" instead of "dispincome". Does there exist a solution to my problem (without either renaming all the variables or editing my TEX-file afterwards)?
>>>> 
>>>> Many thanks for your help!
>>>> 
>>>> Andrea
>>>> 
>>>> 
>>>> *
> 
> 
> 
> *
> *   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