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: RE: Re: extend characters in tabm
From
Nick Cox <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
RE: st: RE: Re: extend characters in tabm
Date
Thu, 14 Oct 2010 12:57:51 +0100
Ho hum.
-tabm2- as said was a quick hack which solves the specific problem posed, but it is not much use for anything else.
Look at the code: all -tabm2- does really is -stack- several variables on the fly into one variable categorised by which variable it was originally, and then call up -table-. But it does not do anything with the rest of your data. So, many things you might reasonably want to do with -table- are just not available. It's a project for someone to look into extending that, except my guess is that there are better ways to proceed.
In general, many of these multiple response problems are much easier with a long data structure, so I think you need to consider a prior -reshape-.
But before you do that I'd look carefully at a program which is the result of a lot more work than went into -tabm- or -tabm2-:
SJ-5-1 st0082 . . . . . . . . . . . . . . . Tabulation of multiple responses
(help _mrsvmat, mrgraph, mrtab if installed) . . . . . . . . B. Jann
Q1/05 SJ 5(1):92--122
introduces new commands for the computation of one- and
two-way tables of multiple responses
In terms of your specific questions:
1. As I understand it, -table- does not offer percents, so neither does -tabm2-. That's a matter for -tabm-.
2. -replace- does I think work with -tabm2-, but not helpfully because the data saved are immediately overwritten with the original data. That could be fixed, but for reasons already given adding a feature here and there to -tabm2- is not the best way forward.
I suggest that questions about Roy Wada's programs are directed to him; he is not a member of Statalist.
Nick
[email protected]
Beth Gifford
(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.
On Wed, Oct 13, 2010 at 12:28 PM, Nick Cox <[email protected]> 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'
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/