top of page
Search

Add family background variables to your UAS analysis: variables from the HRS in the UAS datasets

  • Writer: Francisco Perez Arce
    Francisco Perez Arce
  • May 6
  • 3 min read


ree

Understanding early-life conditions is research-critical – decades of studies show that childhood factors like socioeconomic status and health have cascading effects on adult and late-life health outcomes . Adverse experiences in one’s youth can even contribute to differences in cognitive aging, including higher risks of impairment in older age . By incorporating parental and upbringing variables, UAS researchers can better explore how respondents’ origins shape their later-life trajectories. This enriched analytic dataset empowers social scientists to test life-course hypotheses and deepen our understanding of health and cognitive development across the lifespan.


The Understanding America Study (UAS) fields the entire core HRS survey to all its panelists. One area, which is asked of respondents only the first time they answer the HRS surveys, is respondents’ family background. This includes questions about their parent’s education, their economic status as a child, and whether they experienced illnesses when they were growing up.

I introduce a Stata do-file designed for researchers using UAS data to compile these early-life variables into one dataset. This is especially useful because the UAS Comprehensive File – which merges data from numerous core UAS surveys repeated every two years – currently omits the early-life background variables collected only in the initial surveys. The do-file fills this gap by extracting those retrospective family background metrics (e.g. parental education, childhood living situation) and combining them for analysis.

In particular, the script merges key variables from five UAS survey modules that captured early-life data for different cohorts of panelists: UAS20, UAS95, UAS185, UAS396, and UAS530. Researchers should first download each of these datasets into a folder named “data.” Running the Stata do-file will then merge the files using the unique person identifier (uasid), resulting in a single consolidated dataset with one observation per UAS panelist. This output is saved to an “analytic” folder for easy use in analysis. By unifying these scattered early-life variables, the do-file provides a convenient way to append crucial background information onto the main UAS data.

 

The code I have used is below. Please reach out if you have comments about this code!

 

set more off

capture log close

*Francisco Perez-Arce

*May 6, 2025

***Create a family background dataset

global data  "/Users/ …"

*dataset is saved on analytic folder

global analytic "/Users/…"

 

clear all

 

set maxvar 32000

 

log using "$analytic/family_background_hrs", replace

 

local w=11

foreach survey in uas20 uas95 uas185 uas396 uas530 {

local w=`w'+1

use "$data/`survey'.dta", clear

 

local familybackground b020_ b021_ b022_ b023_ b025_ b026_ b027_ b049_ b035_ b088_

 

local conditions b019_ b099_ b100_ b101_ b102_ b103_ b104_ b105_ b106_ b107_ b108_ b109_ b110_ b111_ b112_ b113_ b114_ b115_ b116_ b117_ b118_ b119_ b120_ b122_ b123_ b124_ b127__10_ b127__11_ b127__12_ b127__13_ b127__14_ b127__1_ b127__2_ b127__3_ b127__4_ b127__5_ b127__6_ b127__7_ b127__8_ b127__9_ b129__10_ b129__11_ b129__12_ b129__13_ b129__14_ b129__1_ b129__2_ b129__3_ b129__4_ b129__5_ b129__6_ b129__7_ b129__8_ b129__9_

 

local immigration b006_ b007_ b008_ b085_ b086_ b087_

 

foreach var in `familybackground' `conditions' {

capture rename `var' r`w'`var' 

}

 

keep uasid r`w'*

tempfile r`w'

save `r`w'', replace

}

 

use `r12', clear

joinby uasid using `r13',unmatched(both)

count

drop _merge

joinby uasid using `r14',unmatched(both)

count

drop _merge

joinby uasid using `r15',unmatched(both)

count

drop _merge

joinby uasid using `r16',unmatched(both)

 

 

foreach var in `familybackground'{

            clonevar ra`var'=r12`var'

            forvalues w=13(1)16{

replace ra`var'=r`w'`var' if ra`var'>=.

            }

 

***b026 and b027 changed across waves, so manually make compatible

drop  rab026 rab027

 

foreach var in b026_ b027_ {

clonevar ra`var'=r12`var'

forvalues w=14(1)16{

replace ra`var'=1 if r`w'`var'==0 & ra`var'>=.

replace ra`var'=2 if r`w'`var'>0 &r`w'`var'<12  & ra`var'>=.

replace ra`var'=3 if r`w'`var'>11 &r`w'`var'<13  & ra`var'>=.

replace ra`var'=4 if r`w'`var'>12 &r`w'`var'<16  & ra`var'>=.

replace ra`var'=5 if r`w'`var'==16   & ra`var'>=.

replace ra`var'=6 if r`w'`var'==17   & ra`var'>=.

replace ra`var'=. if r`w'`var'>17   & ra`var'>=.

}

tab r12`var'

tab ra`var'

}

 

foreach var in `conditions'{

clonevar ra`var'=r12`var'

            forvalues w=13(1)16{

capture replace ra`var'=r`w'`var' if ra`var'>=.

            }

            desc ra`var'

summ ra`var'

}

 

foreach var in  b019_ b099_ b100_ b101_ b102_ b103_ b104_ b105_ b106_ b107_ b108_ b109_ b110_ b111_ b112_ b113_ b114_ b115_ b116_ b117_ b118_ b119_ b120_ b122_ b123_ b124_{

tab ra`var'

replace ra`var'=. if ra`var'==58

}

 

foreach var in b035_ {

replace ra`var'=. if ra`var'==55

}

 

 

foreach var in rab020_ rab021_ rab022_ rab023_ rab025_ rab049_ rab035_ rab088_ rab026_ rab027_ rab019_ rab099_ rab100_ rab101_ rab102_ rab103_ rab104_ rab105_ rab106_ rab107_ rab108_ rab109_ rab110_ rab111_ rab112_ rab113_ rab114_ rab115_ rab116_ rab117_ rab118_ rab119_ rab120_ rab122_ rab123_ rab124_ {

           

summ ra*

 

keep uasid ra*

save "$analytic/family_background_hrs_20250506", replace

 

 
 
 

Comments


bottom of page