[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
Phil Schumm <pschumm@uchicago.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: compact output for series of one-way tabulations |

Date |
Mon, 23 May 2005 15:23:04 -0500 |

At 3:30 PM -0400 5/23/05, Richard Goldstein wrote:

I have a set of 32 variables, each can have any of the categorical values. What I want is an output that (excluding the header) is 32 rows by 5 columns, where the first column is the variable name and columns 2-4 are the three categories (frequency or count) and the last column is the total number having one of the three categories.

Suppose your variables are foo, bar, hello, world, etc., and suppose you have a record identifier named id (you could just use the observation number if you don't):

id foo bar hello world

1. 1 1 1 2 1

2. 2 2 1 3 3

3. 3 3 1 2 .

In this case, you could use the following:

foreach var of varlist foo-world {

ren `var' category`var'

}

reshape long category, i(id) j(variable) string

table variable category, col

I generally prefer the sparseness of the -table- output, but if you want the zeros you could substitute the -tabulate- command instead.

-- Phil

*

* For searches and help try:

* http://www.stata.com/support/faqs/res/findit.html

* http://www.stata.com/support/statalist/faq

* http://www.ats.ucla.edu/stat/stata/

**References**:**st: compact output for series of one-way tabulations***From:*Richard Goldstein <richgold@ix.netcom.com>

- Prev by Date:
**st: RE: compact output for series of one-way tabulations** - Next by Date:
**Re: st: RE: compact output for series of one-way tabulations** - Previous by thread:
**Re: st: RE: compact output for series of one-way tabulations** - Next by thread:
**st: RE: compact output for series of one-way tabulations** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |