Statalist


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

Re: st: AW: generating count and sum variable over two different categorical variables


From   moleps <[email protected]>
To   [email protected]
Subject   Re: st: AW: generating count and sum variable over two different categorical variables
Date   Mon, 11 Jan 2010 17:19:03 +0100

Sorry...


. list pid distr_pop district region yr in 50/60
     | pid   distr_pop   district   region    yr |
     |---------------------------------------------|
 50. | 221     440674          3          1   1953 |
 51. | 869     440674          3          1   1953 |
 52. |   .     139172          8          .   1953 |
 53. | 497     440674          3          1   1953 |
 54. | 684     440674          3          1   1953 |
     |---------------------------------------------|
 55. | 574     158681          6          1   1953 |
 56. | 770     440674          3          1   1953 |
 57. | 454     440674          3          1   1953 |
 58. | 767     227937         18          4   1954 |
 59. | 802     112982         13          2   1954 |
     |---------------------------------------------|
 60. | 790     444041          3          1   1954 |
     +---------------------------------------------+

So what I need to do is generate a variable counting the number of cases from each region for each year and also a variable containing the sum of the population for each region for each year. There are between 3 and 10 districts in each region. 

Any idea or do I have to program it from scratch?

Regards,
M





On 11. jan. 2010, at 17.06, Martin Weiss wrote:

> 
> <> 
> 
> 
> 
> As always: Show an excerpt of your data!
> 
> 
> 
> HTH
> Martin
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von moleps
> Gesendet: Montag, 11. Januar 2010 16:58
> An: [email protected]
> Betreff: st: generating count and sum variable over two different
> categorical variables
> 
> Dear listers,
> I´m doing a survival analysis, but also need to present some graphs on a
> regional level. In other words my data is setup on an individual level with
> categorical variables for year and region. What I need to do is generate a
> count variable for the cases counted over year AND region. Using the - egen
> total- command I´m only able to sum over either year or region. Not both as
> far as I understand. Also is there a way to sum over two categories, not
> just one.
> 
> ie my data is setup according to 
> 
> case year region 
> 
> and i´d like it setup acording to 
> 
> case year region #cases/year/region
> 
> 
> Regards,
> M
> 
> 
> *
> *   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/
> 
> 
> *
> *   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/


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index