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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: comparing variables across time


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: comparing variables across time
Date   Mon, 30 Apr 2012 10:26:32 +0100

I am not sure I follow this as your question stresses joint occurrence
in one place but focus on individual occurrence in another. But

 bysort P1 P2 (year) : gen seq = _n

tags successive joint occurrences of -P1- and -P2-. Then

. list P1 P2 if seq == 1 & year == 1996

shows joint occurrences that first appeared in 1996 and

. count if seq == 1 & year == 1996

counts them.

On Mon, Apr 30, 2012 at 10:15 AM, Navid Asgari <navid@nus.edu.sg> wrote:

> I want to do a pair wise comparison of several variables across different years. I would like to know how many new characters under P1 and P2 (together)exists in year 1996 that did not exists in year 1995.
>
>
>
>  The dataset looks like this:
>
>  Year      P1     P2
> --------  ------- ------
> 1995        A       B
> 1995        A       C
> 1995        D       A
> 1995        E       A
> 1996        B       A
> 1996        A       M
> 1996        A     H
> 1996          A       C
>
>
> So the code should show "2", since character M and H exist under P1 and P2 in the year 1996, but not in 1995.

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


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index