/****************************************************************************** Project: Immigration Data Linkage Project (ircc_link) File: S:\ircc_link\prog\gillesd\concept_samples\birth_region.sas Programmer: Gilles R. Detillieux First Created: Aug. 19, 2022 Revisions: none Input datasets: registry.ircc_crosswalk_1985jan: IRCC linkage dataset registry.ircc_legacy_landing_1985jan: IRCC landing data from 1985 to 1999 registry.ircc_landing_2000jan: IRCC landing data from 2000 to 2017 Description: This program finds birth region of immigrants living in Manitoba, for anyone listed in the IRCC immigration landing datasets and crosswalk. ******************************************************************************/ options nocenter; *** format to convert country code (current or legacy) to region name; %include 'S:\ircc_link\fmtlib\SCCAI_macro_region.sas'; *** Get immigrant cohort from IRCC crosswalk file, include all valid linkages; *** and sort by IRCC's IDNO identifier; proc sort data=registry.ircc_crosswalk_1985jan (keep=filephin filephintype idno acqdt where=(filephintype in ('0','1') and acqdt = '14may2019'd)) out=ircccw (drop=filephintype rename=(filephin=scrphin)) nodupkey; by idno filephin; run; *** Get arrival & landing dates from legacy and current landing datasets; data landing; set registry.ircc_legacy_landing_1985jan (in=in_ll keep=idno arrival_dt landing_dt acqdt country_of_birth_cd) registry.ircc_landing_2000jan (in=in_cl keep=idno arrival_dt landing_dt acqdt country_of_birth); where acqdt = '14may2019'd; * convert birth country to main region/continent class; * from either legacy or current landing data; legacy = in_ll; if legacy then birth_region = put(country_of_birth_cd, SCCAI_macro_region.); else birth_region = put(country_of_birth, SCCAI_macro_region.); label birth_region = 'SCCAI Region or continent of person''s birth country'; label legacy = 'Data came from IRCC legacy landing dataset'; run; *** sort landing data, then merge with crosswalk data, by IDNO identifier; proc sort data=landing; by idno landing_dt; run; data landing; merge ircccw (in=in_cw) landing (in=in_la); by idno; * keep all individuals with linkage and landing records; if in_cw & in_la; run; *** sort by PHIN for duplicate detection; proc sort data=landing; by scrphin landing_dt; run; *** avoid duplicate PHINs and keep earliest landing record per person; data landing; set landing; by scrphin landing_dt; * keep one record per valid PHIN; if first.scrphin & scrphin ^= .; run; *** summarize counts of individuals from each birth region; proc tabulate data=landing; class birth_region / order=formatted; table birth_region, all=''*n='N'*f=comma9. / nocellmerge; title 'Landed immigrants in Manitoba, by birth region'; run; *** a little cleanup; proc delete data=ircccw landing; run;