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 on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Cross Tabulation with more than 2 variables


From   Christoph Engel <engel@coll.mpg.de>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Cross Tabulation with more than 2 variables
Date   Mon, 22 Aug 2011 15:58:56 +0200

Dear Nick,

Thank you for the ultrarapid response. Your FAQ site triggered the idea how to solve the problem in my case:

preserve

gen id = _n

renvars var_a var_b ... var_x \ corr1 - corr10

forvalues i = 1/10 {
    gen int excl`i' = .
    }

forvalues i = 1/10 {
    forvalues j = 1/10 {
        qui count if corr`i' == 1 & corr`j' == 1
        replace excl`i' = r(N) if id == `j'
        }
    }

list excl1 - excl15 in 1/10

restore


Maybe others find this useful in the future

Best

Christoph


Am 8/22/2011 1:55 PM, schrieb Nick Cox:
FAQ     . . . . . . . . . . . . . . . . . . .  Dealing with multiple responses
         . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox and U. Kohler
         4/05    How do I deal with multiple responses?
                 http://www.stata.com/support/faqs/data/multresp.html

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

SJ-3-1  pr0008   Speaking Stata: On structure&  shape: the case of mult. resp.
         . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox&  U. Kohler
         Q1/03   SJ 3(1):81--99                                   (no commands)
         discussion of data manipulations for multiple response data

Nick

On Mon, Aug 22, 2011 at 11:56 AM, Christoph Engel<engel@coll.mpg.de>  wrote:

Maybe I just have not found the right command, or the right keyword. But
since I frequently encountered the problem, I hope someone might point me to
a convenient solution. I want to do cross tabulation for more than 2
variables.

This time, I have summary data about papers that I cannot include in a
meta-study. There is a list of 10 reasons why I had to exclude them. Some
papers are excluded for more than one reason. I have dummy coded these
reasons. I therefore have a dataset of the following form

                    r1    r2    r3    ...    r10

study1        0    1    0    ...        0
study2        1    0    1               0
study3        0    0    1               1

I want to generate a table that looks like this

                    r1    r2    r3    ...    r10
r1                5      0    2            0
r2                2      4    0            0
...

I thus want to say, how often a study had to be excluded for reason 1 alone,
or because it simultaneously suffered from reason 1 and reason 10 (or any
other reason).

Is there a good way to do this? In principle, corr needs this information,
but you do not get sums. tab2 provides the information, but does not collect
it in one table.
*
*   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/



--
_________________________________________________________________
Prof. Dr. Christoph Engel
Max-Planck-Institut zur
Erforschung von Gemeinschaftsgütern
Max Planck Institute for Research on Collective Goods
Kurt-Schumacher-Strasse 10
D 53113 Bonn
Tel. +49/228/91416-10
Fax +49/228/91416-11
e-mail: engel@coll.mpg.de
http://www.coll.mpg.de
http://www.coll.mpg.de/engel.html
http://ideas.repec.org/e/pen22.html
http://papers.ssrn.com/sol3/cf_dev/AbsByAuth.cfm?per_id=251559
_________________________________________________________________

*
*   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