Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: Generate new variable after using long to wide transformation

From   "Helen Gibbs" <>
To   <>
Subject   st: Generate new variable after using long to wide transformation
Date   Wed, 14 Jul 2010 12:07:06 +0100

First of all, thanks for the initial help received to get me started. I am
really beginning to see why I was told I needed to learn STATA over
SPSS...another convert here.

My next question is slightly less foolish I think!

I have a large epidemiological database of twin variables, and I now need to
look at the differences between pairs of twins, and generate more variables
which are differences e.g. weight_dif = (weight of twin_1) - (weight of

So far, I have managed to use the wide to long variable transformation so I
now have two variables called twin_number1 and twin_number2 in place of my
original variable twin_number.

Now I want to calculate the difference between the weight (and about another
376 variables) for each twin pair.

Can someone give me the syntax string for this? I am sure it is probably
quite simple, but after 3 hours of reading on the subject I am not getting

Bear in mind, that if the twin pair are in rows 2 & 3, the weights are in
rows 2 and 3, so I am needing to do a calculation which shows the difference
between twin 1 minus twin 2, that is then made into a positive interger for
the difference, whenever the difference is negative (as we are not
interested in the direction of the difference as the assignment of twin_1
and twin_2 is entirely a matter of circumstance.)

I hope I have explained this clearly, if not and you think you might be able
to help, you can send me a direct email to ask additional questions at

Thanks in advance



*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index