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: RE: summarize by different levels/groups with -egen- ?


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: RE: summarize by different levels/groups with -egen- ?
Date   Fri, 11 Jan 2013 20:14:53 +0000

See also

FAQ     . . Creating variables recording whether any or all possess some char.
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        2/03    How do I create a variable recording whether any
                members of a group (or all members of a group)
                possess some characteristic?
http://www.stata.com/support/faqs/data-management/create-variable-recording/

On Fri, Jan 11, 2013 at 5:58 PM, Rebecca Pope <[email protected]> wrote:

> Joerg's approach is a good one.
>
> My one suggestion would be that if you don't want to drop the
> observations on children who don't have distinct combinations of Class
> & Pathogen, instead of -keep-:
>
> tab pat2 if tag

On Fri, Jan 11, 2013 at 11:25 AM, Joerg Luedicke

>> Consider the following:
>>
>> // Data
>> clear
>>
>> input str2 Class str1 Pathogen
>> A1 H
>> A1 S
>> A1 T
>> A2 S
>> A2 K
>> A3 H
>> A3 D
>> B1 H
>> B1 S
>> end
>>
>> // Flagging classes with at least one H
>> bys Class: egen pat2=max(Pathogen=="H")
>>
>> // To analyze that at class level
>> bys Class: gen tag=_n==1
>> keep if tag
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index