reshape and merge in stata -


i have 3 data sets:

first, called education.dta. contains individuals(students) on many years achieved educations yr 1990-2000. in wide format, can reshape long. presented wide under:

id educ_90 educ_91 ... educ_00 cohort 1 0 1 1 87 2 1 1 2 75 3 0 0 2 90

second, called graduate.dta. contains information of when individuals(students) have finished high school. however, data set not contain several years "snapshot" of individ when finish high school , characteristics of individual students such backgroung (for ex parents occupation).

id schoolid county cohort ... 1 11 123 87 2 11 123 75 3 22 243 90

the third data set called teachers.dta. contains informations teachers @ high school such education, if work full or part time, gender... data set long.

id schoolid county year education 22 11 123 2011 1 21 11 123 2001 1 23 22 243 2015 3

now want merge these 3 data sets.

first, want merge education.dta , graduate.dta on id. problem when education.dta wide: manage merge education , graduation.dta. make loop variables in graduation.dta takes same on years, eksample:

forv j=1990/2000 { gen county j´=. replace countyj´=county }

however, afterwards when reshaping long stata reposts variable id not uniquely identify observations.

further, have tried first reshape education.dta long, , thereafter merge either 1:m or m:1 education master, using graduation.dta.

however stata again reposts id not unique. how deal this?

in next step want merge above teachers.dta on schoolid.

i want final dataset in long format.

thanks :)

i not have format of data, helpful if gave toy dataset @ using dataex (and figure out problem yourself!)

but start, because seeing id not unique, need figure out why there might multiple ids in of datasets. can in graduate.dta or education.dta appear more once? help duplicates useful explore data in way.

because want dataset in long format suggest reshaping education.dta long first, doing merge m:1 id using "graduate.dta" (once figure out why observations showing more once) , then, merge 1:1 schoolid year using "teacher.dta" , have final dataset.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -