Wellyopolis

May 28, 2006

Attaching spousal characteristics for IPUMS datasets in Stata

First draft of a program for attaching spousal characteristics in IPUMS datasets using Stata


capture program drop spousal_char
program spousal_char, sortpreserve
capture drop _merge
tempfile spouses
sort year serial pernum
preserve
keep year serial sploc `0'
rename sploc pernum
foreach i of local 0 {
capture drop sp_`i'
rename `i' sp_`i'
label var sp_`i' "Spouse's `i'"
}

sort year serial pernum
drop if pernum==0
save "`spouses'", replace

restore
merge year serial pernum using "`spouses'"
end

Once you have run the program you can attach spousal characteristics by typing
spousal_char [varlist]

Obviously some improvements could be made ... at a later date.

Posted by eroberts at May 28, 2006 06:16 PM | TrackBack
Comments
The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.