/****************************************************************************** Project: Immigration Data Linkage Project (ircc_link) File: S:\ircc_link\prog\gillesd\concept_samples\years_in_mb.sas Programmer: Gilles R. Detillieux First Created: Sep. 8, 2022 Revisions: - Dec. 20, 2022: - adapted to updated "v2" datasets & split crosswalks - Dec. 22, 2022: - updated end dates & format to cover new data - Jan. 12, 2023: - adapted to most recent "v2" variable names & formats - Mar. 5, 2025: - adapted to 2024 "V2" dataset & variable names, acqdt values - Jul. 22, 2025: - use get_ircc_pr macro to fetch data Input datasets: registry.ircc_crosswalk_1985jan_v2: IRCC linkage dataset, 1985-2023 registry.ircc_legacy_landing_1985jan_v2: IRCC landing data from 1985 to 1999 registry.ircc_landing_2000jan_v2: IRCC landing data from 2000 to 2023 registry.mhmrs_1970jun: MH insurance registry Description: This program finds landing date of immigrants living in Manitoba, for anyone listed in the IRCC immigration landing datasets and crosswalk, then gets the first MB health insurance registry coverage episode ending after landing, to calculate the years of permanent residence in Manitoba. ******************************************************************************/ options nocenter; * formats to categorize landing year and years of residence; proc format; value yearl 1965-1969 = '1965-69' 1970-1974 = '1970-74' 1975-1979 = '1975-79' 1980-1984 = '1980-84' 1985-1989 = '1985-89' 1990-1994 = '1990-94' 1995-1999 = '1995-99' 2000-2004 = '2000-04' 2005-2009 = '2005-09' 2010-2014 = '2010-14' 2015-2019 = '2015-19' 2020-2024 = '2020-24'; value nyearsl . = '' 0 = '0: 0 years' 0<-<5 = '1: < 5 years' 5-<10 = '2: 5-9 years' 10-<15 = '3: 10-14 years' 15-high = '4: 15+ years'; run; *** Get a linked immigrant cohort from IRCC crosswalk and landing tables,; *** keep one record per valid PHIN.; %get_ircc_pr(cohort=, out=landing, dup=first); *** coverage episodes pulled from registry using regcov macro; *** ignore coverage gaps of 360 days or less; %regcov(dsname=landing, startdt=01jan1985, enddt=30nov2022, id=scrphin, outds=regcov, gapdays=360); *** sort by person so we can merge with grouped landing data; proc sort data=regcov; by scrphin covdt enddt; run; *** merge in landing data to find coverage episodes during or after landing; data landing; merge landing (in=in_la) regcov (in=in_co); by scrphin; if in_la and in_co and covdt > . and enddt >= landing_dt; run; *** keep only first coverage episode on or after landing; data landing; set landing; by scrphin; if first.scrphin; *** drop dupl. or registered in error (may show up under another phin); if canccode in ('W','5','6') then delete; pop = 1; * number of years from later of start of coverage or landing date; * to earlier of end of coverage or end of study period; nyears = yrdif(max(covdt, landing_dt), min(enddt, '31dec2021'd)+1, 'actual'); if nyears < 0 then nyears = 0; lyear = year(landing_dt); label lyear = 'Landing Year'; label nyears = 'Number of years as permanent resident in Manitoba'; run; *** summarize counts of individuals by landing year and range of years in MB; proc tabulate data=landing; class lyear nyears / order=formatted; table lyear, nyears*n='N' / nocellmerge; title 'Years lived in Manitoba since landing, by landing year'; format nyears nyearsl.; format lyear yearl.; run; *** a little cleanup; proc delete data=landing regcov; run;