[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Re: matching variable values
Thank you for your help. You saved me at least a day of headaches.
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
save <original-data>, replace
rename ID MomID
rename Height MomHeight
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
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
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.
* For searches and help try: