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: RE: how to -expand- and attach new group id to panel data


From   Austin Nichols <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: how to -expand- and attach new group id to panel data
Date   Thu, 30 Sep 2010 15:13:58 -0400

bys group_id year: g clone=_n
egen newid=group(group_id clone)

On Thu, Sep 30, 2010 at 12:57 PM, Nick Cox <n.j.cox@durham.ac.uk> wrote:
> Two answers:
>
> 1. Why and how are you discriminating between clones of any panel?
>
> 2. -egen, seq()-.
>
> Nick
> n.j.cox@durham.ac.uk
>
> Steve
>
> I have a balanced panel data set with 3 annual observations for each of 3
> groups e.g.,
>
> Group_id        year
> 1               78
> 1               79
> 1               80
> 2               78
> 2               79
> 2               80
> 3               78
> 3               79
> 3               80
>
> Suppose I use -expand- to generate, say, one extra copy of the data for
> group_id 2 and two extra copies of the data for group_id 3.  Now I have:
>
> Group_id        year
> 1               78
> 1               79
> 1               80
> 2               78
> 2               79
> 2               80
> 3               78
> 3               79
> 3               80
> 2               78
> 2               79
> 2               80
> 3               78
> 3               79
> 3               80
> 3               78
> 3               79
> 3               80
>
> How do I give new group_ids to the copied data so that now:
>
> Group_id        year    Newgroup_id
> 1               78      1
> 1               79      1
> 1               80      1
> 2               78      2
> 2               79      2
> 2               80      2
> 3               78      3
> 3               79      3
> 3               80      3
> 2               78      4
> 2               79      4
> 2               80      4
> 3               78      5
> 3               79      5
> 3               80      5
> 3               78      6
> 3               79      6
> 3               80      6

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