You can do this in place:
gen MomHeight = .
levelsof ID, local(ids)
qui foreach id of local ids {
su Height if ID == `id', meanonly
replace MomHeight = r(min) if MomId == `id'
}
There might be a limit on the application
of that with really big datasets.
There is probably a -merge- solution to this
as well. It would be cuter than this if it existed.
Nick
[email protected]
Gregor Franz
> 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.
*
* 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/