| ![](/includes/contimages/spacer.gif) |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Re: matching variable values
Worked nicely!!
Thank you for your help. You saved me at least a day of headaches.
Greg
evan roberts wrote:
Gregor Franz asked how to attach a mother's height to children's
records when the mothers were identified by an ID number
sort MomID
save <original-data>, replace
drop MomID
rename ID MomID
rename Height MomHeight
sort MomID
save <temporary-data-file>
use <original-data>, clear
merge MomID using <temporary-data-file>, nokeep
* You will get a message saying "variable MomID does not uniquely
identify observations in the master data" because there are multiple
children of each mother
* nokeep is necessary so that non-mothers records aren't added to the
file attached to no-one.
assert _merge==1 | _merge==3
Dear Statlisters,
I would like to match the values of one variable to the values of
another variable and then create a third variable. Here is the basic
setup:
ID MomID Height MomHeight
1 . 5 .
2 1 6 5
3 . 6 .
4 1 5.5 5 ...
MomHeight is the variable I want to create. It seems straightforward,
but I just can't come up with the right code.
Thank you for any pointers.
Greg
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/