gen id = _n
Nick
[email protected]
> -----Original Message-----
> From: Nick Cox
> Sent: 22 April 2005 15:32
> To: '[email protected]'
> Subject: RE: Just another data reshaping problem
>
>
> Looks like
>
> gen id = 1
> reshape long group_ ID_g , i(id)
>
> and then a -contract-.
>
> There's really no substitute for detailed study
> of [R] reshape. The FAQ at
>
> http://www.stata.com/support/faqs/data/reshape3.html
>
> may also help.
>
> Nick
> [email protected]
>
> Sascha Robert
>
> > Complex data reshaping unfortunately seems to lie beyond my logical
> > capabilities... so anyone up to a little brain-teaser?
> >
> > My data (simplified) looks like this:
> >
> > time group_1 ID_g1 group_2 ID_g2
> > 1 0 1 1 2
> > 1 0 1 1 3
> > 1 0 2 1 1
> > 1 1 1 0 1
> > 2...
> > and so on.
> >
> > The data says something like (for the first row:) At time
> 1, ID 1 of
> > group 0 encountered ID 2 of group 2. Note that an encounter always
> > involves two entities of two different groups.
> >
> > I would like to reshape the data to the form:
> >
> > group ID num_encounters(*)
> > 0 1 x
> > 0 2 y
> > 1 1 z
> > ...
> >
> > (*)sum of ALL dyadic encounters where ID participated
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/