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

# st: RE: RE: listing all observations of particular id's

 From "Martin Weiss" To Subject st: RE: RE: listing all observations of particular id's Date Sun, 29 Aug 2010 20:16:24 +0200

```<>

On the occasion of this thread and NJC`s solution: Why is it that Stata
requires no -sort-ing in Nick`s solution, but does require it if I prefix
the -by-? (For -max-, -sort-ing should not matter...)

***********
clear*
inp byte(A B)
1 0
1 1
2 0
1 0
2 1
3 0
2 0
3 0
2 1
end
egen anyB1 = max(B) , by(A)
by A: egen other_anyB1 = max(B)
***********

HTH
Martin

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
Sent: Sonntag, 29. August 2010 17:30
To: 'statalist@hsphsun2.harvard.edu'
Subject: st: RE: listing all observations of particular id's

This is an FAQ.

egen anyB1 = max(B) , by(id)
l if anyB1

The rationale is discussed at tedious length in

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/anyall.html>

Nick
n.j.cox@durham.ac.uk

Abhimanyu Arora

The basic simplified problem is as follows.
2 variables A (id) and B(0/1)
I would like to list all observations of all A's for which there is at
least one B=1.
-list- lists only the particular observations...

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