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: Generate new variable after using long to wide transformation


From   Maarten buis <[email protected]>
To   [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index