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
Rebecca Pope <[email protected]>
To
[email protected]
Subject
Re: st: RE: summarize by different levels/groups with -egen- ?
Date
Fri, 11 Jan 2013 11:58:55 -0600
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
Rebecca
On Fri, Jan 11, 2013 at 11:25 AM, Joerg Luedicke
<[email protected]> wrote:
> 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
>
> Joerg
>
<snip>
*
* 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/