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

From |
Philip Ryan <philip.ryan@adelaide.edu.au> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: question about tables |

Date |
Thu, 24 Jul 2003 14:50:39 +0930 |

gen int id =_n /* see help datatypes for your best choice of storage type */

reshape long Age, i(id) j(age_group, string) /* string option needed since age groups are "01" not "1" etc */

table Distr age_group, c(sum Age)

Footnote (or, since it is longer than the solution above, perhaps the solution is more of a Headnote):

Age is perhaps a poor choice of name for the stub of the variables, especially after the -reshape- to long form when only a single "Age" variable remains. The observations on this variable are frequencies, not ages. This is all just cosmetic - Stata doesn't care - but a human might. A good variable label for Age would help explain its meaning, but that's still a patch-over job. You could change the stub on all the AgeXX variables *before* reshaping (using, say, -renpfix- (see -help rename-)) or you could -rename- the single variable Age *after* reshaping and before the -table- command. Note that the renaming *after* the -reshape- will prevent an easy reversal to wide form, should you wish to do this. Anyway, ignoring that wrinkle, you might:

rename Age count

table Distr agegroup, c(sum count)

where, to my mind, "count" is closer to what the variable is about.

Phil

At 04:31 PM 23/07/2003 -0600, you wrote:

Dear stata users: I have a dataset that has the following structure (variables are region, district and persons of corresponding age in each district and region): Region Distr Age01 02 03.....35 1 D01 23 35 45 1 D02 32 30 15 2 D01 28 30 15 2 D02 27 30 15 3 D01 21 30 15 3 D02 24 30 15.... Why kind of command can I use to tell Stata that I want a table like this: Distr Age01 02 03....35 D01 72 95 75 D02 73 90 45.... Where the data are summarized according to the number assigned to the district and totalizing persons for each age. Thanks Rodrigo * * 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/

Philip Ryan Associate Professor, Department of Public Health University of Adelaide 5005 South Australia tel 61 8 8303 3570 fax 61 8 8223 4075 http://www.public-health.adelaide.edu.au/ * * 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/

**Follow-Ups**:**RE: st: question about tables***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**st: question about tables***From:*Rodrigo Briceņo <rbriceno@sanigest.com>

- Prev by Date:
**st: Likelihood Function** - Next by Date:
**st: RE: Multinomial logit** - Previous by thread:
**st: question about tables** - Next by thread:
**RE: st: question about tables** - Index(es):

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