Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Beth Gifford <beth.gifford@duke.edu> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: RE: Re: extend characters in tabm |
Date | Wed, 13 Oct 2010 18:11:23 -0400 |
Hello (I work with Kelly) I tried the new tabm2 and it solved one problem (longer variable labels) but it wasn't clear to me how to get % of respondents. Tabm and tabm2 already have saved me a lot of time so I'm thankful for their development. Below I generated a little example of what were encountering, how we're trying to solve them and the quirks we're running into. It may be there there isn't currently an ideal solution--I'll continue to put more thought into this as it is something that I encounter quite a bit. The goal is to create report ready (or near ready) tables. These tables will be comprised of several items scaled on a likert like scale. webuse bg2, clear // just a dataset that we can all use // making long value labels label define l_label 1 "Strongly Agree" 2 "Neither Agree nor Disagree" 3 "Strongly Disagree" //Creating categorical variables foreach var of varlist bg2cost1 bg2cost2 bg2cost3 bg2cost4 bg2cost5 bg2cost6 { recode `var' min/-1=1 -1/1=2 1/max=3 label val `var' l_label } // making long variable names foreach var of varlist bg2cost1 bg2cost2 bg2cost3 bg2cost4 bg2cost5 bg2cost6 { label var `var' "Something very painfully long and boring, snore, snore" } //tabm is part of the tab_chi packaged developed by Nick Cox tabm bg2*, row nofreq logout, save(c:\temp\beth.xls) replace word excel: tabm bg2*, row nofreq /* This is the command that I am using to save this into excel. logout was developed by Roy Wada and captures log displays. It seems to be saving as an .xml file. (double clicking to open it may lead to problems--right click and open with excel or navigate to it from within excel works fine*/ //tabm2 was developed by Nick Cox relatively quickly today I believe that modifies his tabm command and makes it reliant on table rather than tab tabm2 bg2* exit /* Here are a few quirks that I currently have 1. tabm produces output very close to what I need--but, a. it cuts of the variable names b. combined with logout sometimes the column headings don't line up as they should. 2. tabm2 does a better job than tabm of not cutting off the variable names but, a. I don't know how (or if it is possible) to get the percents displayed. If I use the option for table c(mean X) what is X? b. the replace option for table doesn't work--I thought that that might give me additional options for exporting the table (like the user written program listtab by Roger Newson) */ Any insight is appreciated. Thanks for what I've gotten so far--it really has saved me lots of time. -Beth On Wed, Oct 13, 2010 at 12:28 PM, Nick Cox <n.j.cox@durham.ac.uk> wrote: > That is one of mine. > > No. The help for -tabm- says it all. The extra options for -tabm- are precisely those of -tabulate- for two variables; in turn its options do not include anything like this. But by default you should get the variable label. > > But what you want is programmable. You could, for example, clone -tabm- so that it is -table- that is applied to the results, not -tabulate-. > > Here is a recipe for -tabm2-: > > 1. Copy tabm.ado to tabm2.ado. You now need to edit tabm2.ado in a text editor. > > 2. New header lines are > > *! 1.0.0 NJC 13 October 2010 > program define tabm2, byable(recall) > > 3. The line > > tab `OKlist' `w', `options' > > becomes > > table `OKlist' `w', `options' > > 4. The lines > > if "`trans'" == "" { > tab _stack `data' `w', `options' > } > else tab `data' _stack `w' , `options' > > become > > if "`trans'" == "" { > table _stack `data' `w', `options' > } > else table `data' _stack `w' , `options' > > Nick > n.j.cox@durham.ac.uk > > Kelly > > Is there a way to extend the character width of the variable name with > the tabm command (from -tab_chi- on SSC)? Similar to stubwidth option > in the table command. > > I want to display the variable label as opposed to the variable name. > > > * > * 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/ > -- Elizabeth Gifford, PhD Research Scientist Center for Child and Family Policy Duke University 214 Rubenstein Hall Box 90545 Durham NC, 27708-0545 Work Phone: 919-613-9294 Fax: 919- 684-3731 http://www.duke.edu/~ejg141/ Check out my new creation: http://substanceabuse.ssri.duke.edu/ * * 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/