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" <[email protected]>
To   <[email protected]>
Subject   st: RE: Just another data reshaping problem
Date   Fri, 22 Apr 2005 15:31:59 +0100

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/



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