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: Linking information from other family members


From   Quang Nguyen <quangdata@gmail.com>
To   Fernando Rios Avila <f.rios.a@gmail.com>, statalist@hsphsun2.harvard.edu
Subject   Re: st: Linking information from other family members
Date   Wed, 9 Feb 2011 17:52:51 -1000

Dear Fernando:

Many thanks for your kind help. I highly appreciate it. You have
prosposed an excellent approach. I revised it to make it works as
desired:

bys id: sum(relationship)
forvalues i=1/`r(max)' {
gen y`i'=year_of_migration if migration==1 & pid==`i'
bysort id:egen yy`i'=max(y`i')
drop y`i'
qui sum yy`i'
if r(min)==. drop yy`i'
}

On Wed, Feb 9, 2011 at 10:59 AM, Fernando Rios Avila <f.rios.a@gmail.com> wrote:
> Hi Quang,
>
> I think i can give u a code that could help you a bit with ur problem, but
> the code is rather large. Here it goes:
> ***
> forvalues i=1(1)10 {
> gen y`i'=year_migration if migration==1 & relationship==`i'
> bysort family_id:gen yy`i'=max(y`i')
> }
>
> I think this should do what u want.
>
> Regards
>
> F
> On Wed, Feb 9, 2011 at 8:35 AM, Fernando Rios Avila
> <ecofrax@langate.gsu.edu> wrote:
>>
>>
>> ---------- Forwarded message ----------
>> From: Quang Nguyen <quangdata@gmail.com>
>> To: statalist@hsphsun2.harvard.edu
>> Date: Wed, 9 Feb 2011 03:33:07 -1000
>> Subject: st: Linking information from other family members
>> We have a data that have information on migration status and year of
>> migration for each member. The migration took place in different
>> years. The member we're interested in the child's age of the household
>> when each migration occured. Example of the data as follows:
>>
>> Family_id    Relationship    Migration     Year_migration     Y1     Y2
>>  Y3
>> 1                        1                 1                   1998
>> 1                        2                 1                   2001
>> 1                        3                 1                   2008
>> 1                        4                 0
>>           1998   2001   2008
>> 1                        5                 0
>>           1998   2001   2008
>>
>>
>> How can we generate variables Y1, Y2 , Y3 as above?
>> *
>> *   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/
>> Content-Type: text/plain; charset=US-ASCII
>> Content-Transfer-Encoding: quoted-printable
>> Content-Disposition: inline
>>
>> We have a data that have information on migration status and year of
>> migration for each member. The migration took place in different
>> years. The member we're interested in the child's age of the household
>> when each migration occured. Example of the data as follows:
>>
>> Family_id    Relationship    Migration     Year_migration     Y1     Y2
>>  =
>> Y3
>> 1                        1                 1                   1998
>> 1                        2                 1                   2001
>> 1                        3                 1                   2008
>> 1                        4                 0
>>           1998   2001   2008
>> 1                        5                 0
>>           1998   2001   2008
>>
>>
>> How can we generate variables Y1, Y2 , Y3 as above?
>> *
>> *   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index