/*-------------------------------------------------------------------*/ /* SAS 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) */ /* */ /* SAS Version: 9.2 Windows */ /* */ /* Identical code can be used to add a HIU ID variable */ /* to the Current Population Survey (CPS) using */ /* IPUMS-CPS data */ /*-------------------------------------------------------------------*/ options compress=yes ; /*-------------------------------------------------------------------*/ /* 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 */ /*-------------------------------------------------------------------*/ /* Specify path for file with relevant IPUMS variables */ libname acs_hiu "P:\Health Insurance Unit\ACS"; data hiutemp; if _n_=1 then do; declare hash anyref(ordered: 'yes'); anyref.definekey('serial'); anyref.definedata('serial','pernum'); anyref.definedone(); call missing(serial,pernum); end; set acs_hiu.ipums2010acs end=eof; drop rc; attrib echild label='Eligible child' rel_echild label='Related eligible child' hiup label='Person within HIU' hiu_ref label='HIU reference person' ; /* If age <=18 & not married & no own children in household (HH), set as eligible child */ echild=(age le 18 and marst not in (1,2) and nchild=0); /* Identify eligible children related to HH reference person */ rel_echild=(echild=1 and related >=301 and related <=1001); /* 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 */ if (marst=1 and sex=1) or (marst ne 1 and (sex in (1,2) and nchild gt 0)) then hiup=1; else if marst=1 and sex=2 then hiup=2; else if echild=1 and (poploc ne 0 or momloc ne 0) then hiup=3; else if marst ne 1 and echild=0 and nchild=0 then hiup=4; else if rel_echild=1 then hiup=5; else if rel_echild=0 and echild=1 then hiup=6; /***************************************************/ /* Determine if current obs is a reference person. */ /***************************************************/ hiu_ref=(hiup=1); /***************************************************/ /* If current obs is a reference person, add HH ID */ /* to hash ANYREF and add person number of first */ /* reference person encountered in HH. */ /***************************************************/ if hiu_ref=1 then rc=anyref.ref(); if eof then rc=anyref.output(dataset: 'hhwithref'); run; data hiutemp2; attrib hiu_id length=$9 label='HIU ID' hiu_first_point length=3 hiu_point length=3 hiu_point_rule length=3 hiu_refhhld length=3 ; if _n_=1 then do; declare hash anyref(dataset: 'hhwithref(rename=(pernum=hiu_first_point))', ordered: 'yes'); anyref.definekey('serial'); anyref.definedata('hiu_first_point'); anyref.definedone(); call missing(serial,hiu_first_point); end; set hiutemp; drop rc; /***************************************************/ /* If current obs is present in ANYREF, then */ /* current obs is the first reference person in */ /* the HH */ /***************************************************/ rc=anyref.find(); hiu_refhhld=(rc=0); if hiu_refhhld = 0 then hiu_first_point=1; /* 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 */ if hiup=1 then do; hiu_point=pernum; if hiu_point ne . then hiu_point_rule=1; end; else if hiup=2 then do; if sploc gt 0 then hiu_point=sploc ; else hiu_point=pernum; if hiu_point ne . then hiu_point_rule=2; end; else if hiup=3 then do; if poploc ne 0 then do; hiu_point=poploc; if hiu_point ne . then hiu_point_rule=3; end; else if momloc ne 0 then do; hiu_point=momloc; if hiu_point ne . then hiu_point_rule=4; end; end; else if hiup=4 then do; hiu_point=pernum; hiu_point_rule=5; end; else if hiup=5 then do; hiu_point=hiu_first_point; if hiu_point ne . then hiu_point_rule=6; end; else if hiup=6 then do; hiu_point=pernum; if hiu_point ne . then hiu_point_rule=7; end; hiu_id=cats(put(serial,z7.),put(hiu_point,z2.)); run; /* Save file with HIU variable */ data acs_hiu.acs_2010_hiu; set hiutemp2; run; /***************************************************/ /* END HIU */ /***************************************************/