Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Making permutations of dyads


From   Scott Merryman <[email protected]>
To   [email protected]
Subject   Re: st: Making permutations of dyads
Date   Thu, 19 Dec 2013 15:17:36 -0600

adapted from John-Paul Ferguson's -dyads-  (-ssc desc dyads- for more
info).

 clear
input id   str4 time  block
 1     "8:00"  1
 2     "8:02"  1
 3     "8:02"  1
 4     "8:04"  1
 5     "8:06"  2
 6     "8:07"  2
 7     "8:09"  2
 end
bys block: generate dim = _N
expand dim
sort block id
by block id: generate column = _n
by block :generate id_d = id[_n+column*dim]
drop if mi(id_d)
drop dim column
gen dyad = string(id)+ string(id_d)
order id id_d
l


Scott


On Thu, Dec 19, 2013 at 2:10 PM, Douglas Levy
<[email protected]> wrote:
> Actually, to correct my initial post, I'd be interested in
> *combinations* not *permutations*. So to restate and revise:
> ID    time  5m_block
> 1     8:00  1
> 2     8:02  1
> 3     8:02  1
> 4     8:04  1
> 5     8:06  2
> 6     8:07  2
> 7     8:09  2
>
> For 5 minute time blocks,  I'd want to output a dataset that looks like this:
> Dyad
> 12
> 13
> 14
> 23
> 24
> 34
> 56
> 57
> 67
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index