Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Just another data reshaping problem


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Just another data reshaping problem
Date   Fri, 22 Apr 2005 16:02:53 +0100

gen id = _n 

Nick 
n.j.cox@durham.ac.uk 

> -----Original Message-----
> From: Nick Cox 
> Sent: 22 April 2005 15:32
> To: 'statalist@hsphsun2.harvard.edu'
> 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 
> n.j.cox@durham.ac.uk 
> 
> 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/



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