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

From |
Shehzad Ali <sia500@york.ac.uk> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: generate sum by categorical variable |

Date |
23 Sep 2008 17:45:38 +0100 |

Hi,

I have an individual patient level data with two variables of interest, one is the number of weeks spent by each patient in the study (values between 1 and 52) and other being stratum they belong to (values between 1 and 3). I want to generate a new variable (total_weeks) that summarises the total number of weeks spent by each stratum. So the new variable will have 3 values only, one for each stratum. I can obviously use -sum- and -r(sum) to generate separate variables by strata but I was wondering there must be a quicker way of doing it in one line. Can you advise please?

Thank you,

Shehzad

*

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

**Follow-Ups**:**Re: st: generate sum by categorical variable***From:*Nick Cox <n.j.cox@stata.com>

**Re: st: generate sum by categorical variable***From:*"Eva Poen" <eva.poen@gmail.com>

- Prev by Date:
**Re: st: numbering observations when variables change** - Next by Date:
**Re: st: generate sum by categorical variable** - Previous by thread:
**st: numbering observations when variables change** - Next by thread:
**Re: st: generate sum by categorical variable** - Index(es):

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