On 7/29/08, Cesare Fracassi <[email protected]> wrote:
> Hi All,
>
> I have a db that looks like this:
>
> ID N
> 1 1
> 2 0
> 3 4
> 4 2
> 5 2
> 6 0
> .........
> 10 1
>
>
> (the actual db is much larger than that)
>
> I would like to create a new dataset that contains the nxn possible
> combinations of observations and takes the differences between the Ns:
>
> ID1 ID2 DeltaN
> 1 1 0 1 2 1
> 1 3 -3
> 1 4 -1
> ........................
> 1 10 0
> 2 1 -1
> 2 2 0
> 2 3 -4
> .......
>
> and so on for the nxn possible combinations...
>
> any idea how to code that in stata?
Create a 10x10 matrix, compute the differences between N[i] and N[j]
for each i and j. Store the resulting matrix into a dataset. reshape
wide to long.
Best regards, Sergiy.
>
> thanks in advance...
>
> Cesare
>
>
>
>
>
>
>
>
>
>
> *
> * 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/
>
*
* 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/