Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Need help with working across variables


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
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 <corybsmith@gmail.com> 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 <corybsmith@gmail.com> 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
>> <michaelstewartresearch@gmail.com> 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index