stata - Generating variable observations for one id to be observation for new variable of another id -


i have data set allows linking friends (i.e. observing peer groups) , thereby 1 can observe characteristics of individual's friends. have 8 digit identifier, id, each id's friend id's (up 10 friends), , many characteristic variables.

i want take individual , create variables foreign born status of each friend.

i have indicator each person 1 if foreign born. below small example, 1 friend. notice, mf1 means male friend 1 , mf1id id number male friend 1. respondents list 5 male friends , 5 female friends.

example

so, need stata @ mf1id , match down id column, on f_born matched id, , input value of f_born there original id under mf1f_born.

edit: did poor job of explaining data structure. have cross section 1 observation per unique id. row 1 first 8 digit id number variables following on row. repeating id numbers between friend id's listed each person (mf1id example) , id column. hope bit more clear.

kevin crow wrote vlookup makes sort of thing pretty easy:

use http://www.ats.ucla.edu/stat/stata/faq/dyads, clear drop team y rename (rater ratee) (id mf1_id) bys id: gen f_born = mod(id,2)==1  net install vlookup vlookup mf1_id, gen(mf1f_born) key(id) value(f_born) 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -