/**************************************** STATA code: Adding a Health Insurance Unit (HIU) ID variable to the American Community Survey (ACS) using IPUMS-USA data March 2012 Developed by the University of Minnesota, State Health Access Data Asssitance Center (SHADAC) Identical code can be used to add a HIU ID variable to the Current Population Survey (CPS) using IPUMS-CPS data ****************************************/ /****************************************** Download extract from IPUMS. To create the HIU download the following variables: YEAR, DATANUM, SERIAL, HHWT, GQ, PERNUM, PERWT (pre-selected by IPUMS) and STATEFIP, MOMLOC, POPLOC, SPLOC, NCHILD, RELATE, AGE, SEX, MARST Open file with relevant IPUMS variables ******************************************/ use "P:\Health Insurance Unit\ACS\ipums2010acs.dta" ***************************************** ** Define oldest possible age of children ***************************************** local childage 18 ***************************** *** Define common labels ***************************** lab def yesno 0"No" 1"Yes" ******************************************************* ** Flag persons eligible to be linked to HIU as a child ******************************************************* /* If age <='childage' & not married & no own children in household (HH), set as eligible child */ gen echild=(age<=`childage' & marst!=1 & marst!=2 & nchild==0) lab var echild "Eligible to be linked to HIU as Child" lab val echild yesno ************************** ** Create HIU person types ************************** /* Identify eligible children related to HH reference person */ gen rel_echild= (echild==1 & (related>=301 & related<=1001) ) lab var rel_echild "Related Eligible Child" # d; /* HIUP may misclassify. Its purpose is to separate out dependents. HIUP==1 (HIU reference person): Is only applied to individuals in multiple person groups. People that end up in single person HIU may or may not be HIU reference people */ /* HIUP=1: Set married male as Ref in own HIU OR single (no spouse present) male with own children in HH (father) OR single (no spouse present) female with own children in HH (mother) HIUP=2: Female spouse (not absent) HIUP=3: Eligible child with either or both mother/father in HH HIUP=4: If not married (no spouse present), not an eligible child, and no own children in HH, set as single adult HIUP=5: If related eligible child and not yet assigned person type set as related singleton eligible child HIUP=6: If unrelated eligible child and not yet assigned person type set as unrelated singleton eligible child */ gen hiup=.; replace hiup=1 if (marst==1 & sex==1) | (sex==1 & nchild>0 & marst!=1) | (sex==2 & nchild>0 & marst!=1); replace hiup=2 if (marst==1 & sex==2); replace hiup=3 if echild==1 & (poploc!=0 | momloc!=0); replace hiup=4 if marst!=1 & echild==0 & nchild==0; replace hiup=5 if echild==1 & hiup==. & rel_echild==1; replace hiup=6 if echild==1 & hiup==. & rel_echild==0; lab var hiup "HIU Person Type"; # d cr lab def hiup 1"HIU Ref" 2"Dependent Female Spouse" 3"Eligible Child" /// 4"Single Adult" 5"Related Singelton Child" 6"Unrelated Singleton Child", modify lab val hiup hiup ************************************************************ ** Create a pointer for related children without parents ************************************************************ /*Flag HIU Referents*/ gen hiu_ref=(hiup==1) lab var hiu_ref "HIU Reference Person" /*Flag households with HIU referents*/ egen hiu_refhhld=max(hiu_ref), by(serial) lab var hiu_refhhld "HIUP==1 Present in HH" /*Flag first HIU referent person in household with their person number, if one exists*/ egen first_hiuref=min(pernum) if hiup==1, by(serial) /*Apply first HIU ref person number to everyone in household, if one exists*/ egen first_point=min(first_hiuref), by(serial) /*Point to first record in HH if no HIU Referent in Household*/ replace first_point=1 if first_point==. lab var first_point "Point to First HIU REF of HH" *************************** ** Generate the HIU pointer *************************** /*Initate rule flag to indicate where HIU pointer originates*/ gen hiu_point_rule=. /*Create Pointers and Flag Source*/ /* HIU_POINT_RULE=1: Point referent to self HIU_POINT_RULE=2: Point married dependent to their spousal referent (by sploc) Point married dependent (but with no spouse listed) to themselves HIU_POINT_RULE=3: Point child to father (by poploc) if father present HIU_POINT_RULE=4: Point child to mother (by momloc) if father absent and mother present HIU_POINT_RULE=5: Point single adult to self HIU_POINT_RULE=6: Point related singleton child to HIU ref HIU_POINT_RULE=7: Point unrelated children to self */ gen hiu_point=pernum if hiup==1 replace hiu_point_rule=1 if hiu_point !=. replace hiu_point=sploc if hiup==2 & sploc>0 replace hiu_point=pernum if hiup==2 & sploc==0 replace hiu_point_rule=2 if hiu_point !=. & hiu_point_rule==. replace hiu_point=poploc if hiup==3 & hiu_point==. & poploc!=0 replace hiu_point_rule=3 if hiu_point !=. & hiu_point_rule==. replace hiu_point=momloc if hiup==3 & hiu_point==. & momloc!=0 replace hiu_point_rule=4 if hiu_point !=. & hiu_point_rule==. replace hiu_point=pernum if hiup==4 replace hiu_point_rule=5 if hiu_point !=. & hiu_point_rule==. replace hiu_point=first_point if hiup==5 replace hiu_point_rule=6 if hiu_point !=. & hiu_point_rule==. replace hiu_point=pernum if hiup==6 replace hiu_point_rule=7 if hiu_point !=. & hiu_point_rule==. lab var hiu_point "HIU Ref Pointer" lab var hiu_point_rule "HIU Pointer Rule" lab def hiu_point_rule 1"Referent" 2"Married Dependent to Spouse Ref" 3"Child to Father" /// 4"Child to Single Mother" 5"Single Adult" /// 6"Point to Ref: Related Single Child" 7"Single Child", modify lab val hiu_point_rule hiu_point_rule ****************** ** Create HIU ID ****************** tostring (serial),gen(hh_id) format(%07.0f) tostring (hiu_point), gen(hiu_point_s) format(%02.0f) *Concatenate HH_ID POINTS to form HIU ID* gen hiu_id=hh_id+hiu_point_s lab var hiu_id "HIU ID" **************************** * Save file with HIU variable **************************** save "P:\Health Insurance Unit\ACS\acs_2010_hiu", replace *************************************** ********* END HIU ********************* ***************************************