UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

Stata Code Fragment: 
Matching Kids to Parents with ipums data

Here is a baby example showing how you can match up kids with parents with ipums data.

clear
input hhid pernum age momloc poploc
1 1 50 0 0
1 2 60 0 0
1 3 10 2 1
2 1 70 0 0
2 2 80 0 0
2 3 30 2 1
3 1 20 0 0
3 2 22 0 0
3 3  2 2 1
3 4  1 2 1
4 1 45 0 0
4 2  8 1 0
4 3  9 1 0
5 1 44 0 0
5 2 20 1 0
5 3 22 0 0
5 4  2 3 2
5 5  1 3 2
end

sort hhid pernum
save all, replace

rename age momage
save moms, replace

use all, clear
rename age dadage
save dads, replace

use all, clear
rename age kidage
keep if kidage >=0 & kidage <=24
save kids, replace

drop pernum
rename momloc pernum
sort hhid pernum
merge hhid pernum using moms
keep if _merge==3 | _merge==1
generate nomom = _merge==1
list
drop _merge

drop pernum
rename poploc pernum
sort hhid pernum
merge hhid pernum using dads
keep if _merge==3 | _merge==1
generate nodad = _merge==1

drop if nomom & nodad
list





How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California