* GENERATE FAMILY LINKAGES 1974-2019; * This program uses an iterated version of the RegRelation macro to find relationships up to; * Great-Grandparents from the Manitoba-born population 1974-2019; * This investigation was carried out under the permissions of the BAM project; * The iterated version of the macro takes the results of the first pass through the; * relationship macro and runs these through a second time, and then the results of; * that pass are run through a third time. The resulting relationships are three levels; * removed from the original population cohort (i.e. Parents of Parents of Parents); * All types of relationships thus discovered are tabulated for each cohort year; * from 1974 to 2019; * Include iterated version of RegRelation; %include "S:\bam\maclib\Relationships iterative to Level 3.sas"; * Births in 1974-2019 calendar years; data pop; set registry.mhmrs_regphin_19702020; if "01jan1974"d <= ribirthdt <= "31dec2019"d; rename ribirthdt=birthdt; * keep scrphin regyear ribirthdt; run; * Sort by SCRPHIN REGYEAR to take BIRTHDT from most recent registry; proc sort data= pop; by scrphin regyear; run; data pop; set pop; by scrphin regyear; if last.scrphin; run; %regcov(dsname=pop, startdt=01jan1970, enddt=November 30 2020, id=scrphin, cleanup=0); data cov_intervals; set sreg; * Drop this birthdate and keep the one from REGPHIN; * This birthdate is used internally in the relation macro and I want them to be consistent; drop birthdt; run; data cov_intervals; merge cov_intervals(in=a) pop(in=b keep=scrphin birthdt); by scrphin; if a; if covdt'30jun2020'd then delete; * Adjust enddt after June 30 2020 to be June 30 2020; * Not only the usual Registry offset needs to be adjusted, but some; * cancode=V records have a future cancel date (visa); * We are really only interested in them up to June 30 2020; if enddt>'30jun2020'd then enddt='30jun2020'd; * Years follow-up from coverage to earlier of ENDDT or June 30 2020; followup=yrdif(covdt,enddt); length byear 3; byear=year(birthdt); run; %macro yearsumm(year); data popyr; set pop; where byear=&year; run; ods html select none; ods listing select all; %iterated_relationships(popyr,keeplist=birthdt covbirth covdt sex enddt canccode followup); * At this point we have POP, the denominator file, and ALLREL, relationships found for POP; * To fill in Table 1, we need a count of people (covered from birth, although that can be relaxed later on); * and the percentage with at least 1 relative meeting each of the categories specified.; * I will also count the relatives of each type because they will probably ask for that eventually; * Create binary variables flagging relationship types in Table 1; data table1; set allrel; by scrphin; if first.scrphin then do; has_mom=0; has_dad=0; has_sibfullnontwin=.; has_sibhalf=.; has_twin=0; has_sibsamemom=.; has_mat_gmom=.; has_mat_gdad=.; has_pat_gmom=.; has_pat_gdad=.; has_bioaunt=.; has_biouncle=.; has_cousin=.; has_ggparent=.; num_sibfullnontwin=0; num_sibhalf=0; num_sibsamemom=0; num_mat_gmom=0; num_mat_gdad=0; num_pat_gmom=0; num_pat_gdad=0; num_bioaunt=0; num_biouncle=0; num_cousin=0; num_ggparent=0; end; retain has_mom has_dad has_twin num_sibfullnontwin num_sibhalf num_sibsamemom num_mat_gmom num_mat_gdad num_pat_gmom num_pat_gdad num_bioaunt num_biouncle num_cousin num_ggparent; * Level 1 relationships; if level=1 then do; * Mom; if relation_lev1='Parent - Female' then has_mom=1; * Dad; if relation_lev1='Parent - Male' then has_dad=1; * Twins; if twin_lev1=1 then has_twin=1; * Full Siblings, not twins; if sibtype_lev1='FULL' and twin_lev1=0 then num_sibfullnontwin=num_sibfullnontwin+1; * Confirmed Half Siblings; if sibtype_lev1 in ('HMOM','HDAD') then num_sibhalf=num_sibhalf+1; * Siblings, same mother, unknown father; if sibtype_lev1='UMOM' then num_sibsamemom=num_sibsamemom+1; end; * Level 2 relationships; if level=2 then do; * Maternal Grandmother; if reltarget_lev2='UU' and relation_lev1='Parent - Female' and relation_lev2='Parent - Female' then num_mat_gmom=num_mat_gmom+1; * Maternal Grandfather; if reltarget_lev2='UU' and relation_lev1='Parent - Female' and relation_lev2='Parent - Male' then num_mat_gdad=num_mat_gdad+1; * Paternal Grandmother; if reltarget_lev2='UU' and relation_lev1='Parent - Male' and relation_lev2='Parent - Female' then num_pat_gmom=num_pat_gmom+1; * Paternal Grandfather; if reltarget_lev2='UU' and relation_lev1='Parent - Male' and relation_lev2='Parent - Male' then num_pat_gdad=num_pat_gdad+1; * Biological Aunt; * Generally Aunts/Uncles can be found at Level 2 or 3, but Level 3 are by marriage (e.g. USX) so; * they want just biological Level 2 (US) relationships; if reltarget_lev2='US' and relation_lev2='Sibling - Sister' then num_bioaunt=num_bioaunt+1; * Biological Uncle; if reltarget_lev2='US' and relation_lev2='Sibling - Brother' then num_biouncle=num_biouncle+1; end; * Level 3 relationships; if level=3 then do; * Cousin; if reltarget_lev3='USD' then num_cousin=num_cousin+1; * Great-Grandparent; if reltarget_lev3='UUU' then num_ggparent=num_ggparent+1; end; if last.scrphin then do; has_sibfullnontwin=(num_sibfullnontwin>0); has_sibhalf=(num_sibhalf>0); has_sibsamemom=(num_sibsamemom>0); has_mat_gmom=(num_mat_gmom>0); has_mat_gdad=(num_mat_gdad>0); has_pat_gmom=(num_pat_gmom>0); has_pat_gdad=(num_pat_gdad>0); has_bioaunt=(num_bioaunt>0); has_biouncle=(num_biouncle>0); has_cousin=(num_cousin>0); has_ggparent=(num_ggparent>0); output; end; label has_mom='Mother' has_dad='Father' has_twin='Sibling type: Twin' has_sibfullnontwin='Sibling type: Full, non-twin' has_sibhalf='Sibling type: Half (both parents known)' has_sibsamemom='Sibling type: Same mother, unknown father' has_mat_gmom='Maternal Grandmother' has_mat_gdad='Maternal Grandfather' has_pat_gmom='Paternal Grandmother' has_pat_gdad='Paternal Grandfather' has_bioaunt='Biological Aunt' has_biouncle='Biological Uncle' has_cousin='First Cousin' has_ggparent='Great-Grandparent' followup='Follow-up (yrs): To end or June 30 2020'; run; ods html select all; proc tabulate data=table1 noseps; var followup has_mom has_dad has_twin has_sibfullnontwin has_sibhalf has_sibsamemom has_mat_gmom has_mat_gdad has_pat_gmom has_pat_gdad has_bioaunt has_biouncle has_cousin has_ggparent; tables followup*(n*f=8.0 mean*f=7.1 median*f=7.1 min*f=7.1 max*f=7.1); tables (has_mom has_dad has_twin has_sibfullnontwin has_sibhalf has_sibsamemom has_mat_gmom has_mat_gdad has_pat_gmom has_pat_gdad has_bioaunt has_biouncle has_cousin has_ggparent), mean*f=percent10.3 / rts=50; title "Calendar Birth Year &year: Presence of various relationships to birth cohort"; run; ods html select none; * Save file to combine at end; data pop_&year; set table1; run; %mend; * Generate tables for years in Table 1. Complete years will be done in a separate program; ods html file = 'S:\bam\prog\randyw\MMC\file creation\Table 1 output 1979 to 2019 with total.html'; * Yet another macro to call the year summary macro for 1974 to 2019; %macro makeyears; %do y=1974 %to 2019; %yearsumm(&y); %end; %mend; %makeyears; data allyears; set pop_1974-pop_2019; run; ods html select all; proc tabulate data=allyears noseps; var followup has_mom has_dad has_twin has_sibfullnontwin has_sibhalf has_sibsamemom has_mat_gmom has_mat_gdad has_pat_gmom has_pat_gdad has_bioaunt has_biouncle has_cousin has_ggparent; tables followup*(n*f=8.0 mean*f=7.1 median*f=7.1 min*f=7.1 max*f=7.1); tables (has_mom has_dad has_twin has_sibfullnontwin has_sibhalf has_sibsamemom has_mat_gmom has_mat_gdad has_pat_gmom has_pat_gdad has_bioaunt has_biouncle has_cousin has_ggparent), mean*f=percent10.3 / rts=50; title "Calendar Birth Years 1974-2019: Presence of various relationships to birth cohort"; run; ods html close;