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: Need help with working across variables


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Need help with working across variables
Date   Sun, 10 Feb 2013 10:50:23 +0000

See

http://www.stata.com/support/faqs/data-management/listing-observations-in-group/

-egen- is not needed here.

bysort id (whatever) : gen same = whatever == whatever[1] | missing(whatever)

Any non-missing numeric values are sorted to the beginning of each group.

This is really is an FAQ: e.g.

http://www.stata.com/statalist/archive/2013-01/msg00502.html

Nick

On Sun, Feb 10, 2013 at 5:57 AM, Cory Smith <[email protected]> wrote:

> You'll need the "by" command if you have used it before.
>
> Cory
>
> On Sun, Feb 10, 2013 at 12:56 AM, Cory Smith <[email protected]> wrote:
>> All non-missing observations will be the same iff the minimum value
>> equals the maximum value. You can fill in the rest given the previous
>> code, I think.


>> On Sun, Feb 10, 2013 at 12:53 AM, Michael Stewart
>> <[email protected]> wrote:
>>> Dear Cory,
>>> This works,
>>> Thanks a lot
>>> on the same lines have another question
>>>
>>> id   var
>>> 1    2
>>> 1    2
>>> 1    3
>>> 1    2
>>> 2    1
>>> 2    1
>>> 2    1
>>> 2    .
>>> 2    1
>>> 3    1
>>> 3   2
>>> 3   4
>>>
>>> How do I check of all(nonmissing) observations for a particular id are the same
*
*   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