Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: egen question


From   john metcalfe <[email protected]>
To   [email protected]
Subject   Re: st: egen question
Date   Fri, 19 Nov 2010 21:04:25 -0800

Thank you very much. That works.
John

On Fri, Nov 19, 2010 at 5:54 PM, David Kantor <[email protected]> wrote:
> Try this:
>
> sort year jurisdiction
> by year jurisdiction: gen int ncases= _N
> by year jurisdiction: gen byte j = ncases>=5 & _n==1
> by year: egen int njuris = total(j)
>
> Possibly, you could condense the first two -gen-s to one line:
> by year jurisdiction: gen int j =  _N>=5 & _n==1
>
> The final result is a constant by year; you could, instead collapse it, if
> you prefer.
>
> HTH
> --David
>
> At 08:32 PM 11/19/2010, John wrote:
>>
>> Dear Statalist,
>> I have a cross-sectional database of 50,000 individuals (cases)
>> diagnosed within one of 50 jurisdictions over a 16 year period.
>> For each year, I would like to tally the number of jurisdictions
>> diagnosing 5 or more cases.
>> Does anyone know of a simple way to generate this variable using
>> -egen- or some other method?
>> Many thanks,
>> John
>
> *
> *   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index