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, statalist.org is already up and running.


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

Re: st: Generate new variable after using long to wide transformation


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Generate new variable after using long to wide transformation
Date   Wed, 14 Jul 2010 11:44:57 +0000 (GMT)

--- On Wed, 14/7/10, Helen Gibbs wrote:
> 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 twin_2)

*----------- begin example -------------
drop _all
input famid twinid weight
      1      1     10
	  1      2     15
	  2      1     20
	  2      2     15
end
reshape wide weight, i(famid) j(twinid)
gen difweight = weight1 - weight2
list
*------------ end example --------------
(For more on examples I sent to the Statalist see: 
http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

*
*   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/


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