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

From |
Eunsu Ju <eunsu.ju@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Creating variables of parents education when ID is known |

Date |
Sun, 15 Mar 2009 13:20:21 -0500 |

Thanks Nick, As you mentioned, another way you presented is easier for me to understand. I appreciate your help. Eunsu On Sun, Mar 15, 2009 at 12:55 PM, Nick Cox <n.j.cox@durham.ac.uk> wrote: > We don't know what you don't tell us! > > The FAQ remains relevant to your version of this problem. The mean of one value (or the maximum, or the minimum) is precisely that value. Section 5 is closest. > > Here is another way to do it, which is not elegant, but may be easier to understand. > > gen Fedu = . > > qui forval i = 1/`=_N' { > su Edu if PID == FPID[`i'] & FID == FID[`i'], meanonly > replace Fedu = r(min) in `i' > } > > I assume numeric variables. > > Nick > n.j.cox@durham.ac.uk > > Eunsu Ju, Ph.D. candidate > > Thanks much, Martin. > > Actually, I checked the FAQ page you posted before I sent out my question. > I think no example in the page is similar to my question. Am I missing > something? > I don't want to generate family mean but to have exact value of > someone in the family. > If there person number is constant, egen function may solve the problem. > Unfortunately, person number varies in my case. > > If you think my question is answered in the page, could you please > specify example number that I pay more attention to. > > On Sun, Mar 15, 2009 at 3:12 AM, Martin Weiss <Martin.Weiss1@gmx.de> wrote: > >> Try http://www.stata.com/support/faqs/data/members.html > > Eunsu Ju, Ph.D. candidate > >>> I would like to generate a new variable which contains the information >>> of parents, e.g. dad's education. >>> My data looks like below. >>> >>> FID PID Var1 Edu Var3 FFID FPID Fedu >>> >>> 1001 100 XXX XXX XXXX ---- ---- ???? >>> 1001 200 XXX XXX XXXX ---- ---- ???? >>> 1001 300 XXX XXX XXXX 1001 100 ???? >>> 1001 310 XXX XXX XXXX 1001 100 ???? >>> 1002 101 XXX XXX XXXX ---- ---- ???? >>> 1002 102 XXX XXX XXXX ---- ---- ???? >>> 1002 200 XXX XXX XXXX 1002 101 ???? >>> 1002 300 XXX XXX XXXX 1002 101 ???? >>> 1002 310 XXX XXX XXXX 1002 200 ???? >>> 1002 320 XXX XXX XXXX 1002 200 ???? >>> >>> >>> *Note: FID = Family ID; PID = Person ID; FFID = Father's family ID; >>> FPID = Father's person ID; Fedu = Father's Education >>> >>> >>> What I want to do is to have the last (far right) column, which is not >>> included in the dataset. >>> (I want to do this kind of works for other variables, e.g. Var1 and Var3.) >>> >>> What is the best & simplist way to do this in stata? >>> >>> I think I can do this like the following. >>> 1) Split the data set into two files so that one file contains Dad's >>> FID and Dad's PID, and the other has all others. >>> 2) Then, rename FID and PID in the second file as Dad's FID and Dad's PID. >>> 3) Rename Edu (and/or other variables I want to have at Dad's level) >>> as Dad's Edu >>> 4) Merge two files by matching Dad's FID and Dad's PID. >>> > > * > * 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/ > * * 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/

**References**:**st: Creating variables of parents education when ID is known***From:*Eunsu Ju <eunsu.ju@gmail.com>

**Re: st: Creating variables of parents education when ID is known***From:*"Martin Weiss" <Martin.Weiss1@gmx.de>

**Re: st: Creating variables of parents education when ID is known***From:*Eunsu Ju <eunsu.ju@gmail.com>

**RE: st: Creating variables of parents education when ID is known***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: re: Is there a similar output command as outreg for Summary?** - Next by Date:
**Re: st: re: Is there a similar output command as outreg for Summary?** - Previous by thread:
**RE: st: Creating variables of parents education when ID is known** - Next by thread:
**Re: st: Return code 199 after redoing the example in stata reference** - Index(es):

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