/*___________________________________________________________________ ¦ MACRO: PHINCHECK ¦ ¦ JOB: Data Quality ¦ ¦ PROGRAMMER: Mahmoud Azimaee ¦ ¦ DATE: April 2011 ¦ ¦ DESCRIPTION: For a given table, this Macro performs a few ¦ ¦ checks on the validity of PHIN particulary on ¦ ¦ SCRPHIN variable. For all individual specific PHINs¦ ¦ PHINCHEK checks the third and fifth positions of ¦ ¦ PHINs which must be 0 and 9. It also checks the ¦ ¦ distribution of the first position and compares it ¦ ¦ with the corresponding PHINs from registry files ¦ ¦ and if there is a significant difference it will be¦ ¦ flagged on the results. ¦ ¦ PARAMETERS: DS= Name of Dataset ¦ ¦ REGYR= The latest year which a registry file is ¦ ¦ available for. (Default=2010) ¦ ¦ PHIN= Name of PHIN variable(Default=SCRPHIN) ¦ ¦ TYPE=Name of PHINTYPE variable(Default=SCRPHINTYPE)¦ ¦ EXAMPLE: %PHINCHECK (DS=health.MHCPL_SPsection_19922010); ¦ ¦ EXAMPLE: %PHINCHECK (DS=health.wrha_ccic_cc_1988jul, ¦ ¦ REGYR=2010); ¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯*/ **********************************************************************; %MACRO PHINCHECK (DS,REGYR=2010, PHIN=SCRPHIN, TYPE=SCRPHINTYPE); %PUT ___________________________________________________________________; %PUT ¦ Manitoba Centre for Health policy (MCHP) ¦; %PUT ¦ MACRO: PHINCHECK ¦; %PUT ¦ JOB: Data Quality ¦; %PUT ¦ PROGRAMMER: Mahmoud Azimaee ¦; %PUT ¦ DATE: April 2011 ¦; %PUT ¦ Running for: &DS; %PUT ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯; proc format; value $phintype '0'='0 MH verified against concurrent registries' '1'='1 MH redirected to this ScrPHIN from FILEPHIN' '2'='2 MCHP modified sibling''s ScrPHIN' '3'='3 MCHP assigned ScrPHIN from Registry' '4'='4 MCHP db specific ScrPHIN - No MH found' '5'='5 MCHP db specific ScrPHIN - personid not incl in crosswalk' '6'='6 Not Defined June 2010' '7'='7 HCN is not Manitoba Resident' '8'='8 Missing or unspecified' '9'='9 System, not individual ScrPHIN' ; run; proc sort data=&DS (keep=&PHIN &TYPE) out=phin nodupkey; by &PHIN; run; data phin; set phin; if &TYPE='0' then do ; *if mod(&PHIN,1000000)=0 then do; phin_1=(&PHIN - mod(&PHIN,100000000000000))/100000000000000; *phin_2=mod((&PHIN - mod(&PHIN,10000000000000))/10000000000000,10) ; phin_3=mod((&PHIN - mod(&PHIN,1000000000000))/1000000000000,10) ; *phin_4=mod((&PHIN - mod(&PHIN,100000000000))/100000000000,10) ; phin_5=mod((&PHIN - mod(&PHIN,10000000000))/10000000000,10) ; *phin_6=mod((&PHIN - mod(&PHIN,1000000000))/1000000000,10) ; *phin_7=mod((&PHIN - mod(&PHIN,100000000))/100000000,10) ; *phin_8=mod((&PHIN - mod(&PHIN,10000000))/10000000,10) ; *phin_9=mod((&PHIN - mod(&PHIN,1000000))/1000000,10) ; end; label phin_1='1st Digit of PHIN' phin_3='3rd Digit of PHIN' phin_5='5th Digit of PHIN'; run; Title 'Check Cross-Walk Linkage'; /* proc freq data=phin NLEVELS;*/ /* table phin_1 / NOCUM TESTP=(10.08 9.75 9.59 9.7 9.69 10.02 10.26 10.36 10.31 10.23) out=phinfreq;*/ /* where &TYPE='0';*/ /* run;*/ proc freq data=phin noprint; table phin_1 / NOCUM out=phinfreq; where &TYPE in('0','1','2','3','6'); run; data reg; set REGISTRY.MHMRS_UNIQPHIN_1970®YR; if &TYPE in('0','1','2','3','6') & input('90-01-01',YYMMDD8.)<= RIENDDT ; phin_1=(SCRPHIN - mod(SCRPHIN,100000000000000))/100000000000000; keep SCRPHIN phin_1; run; proc sort data=reg nodupkey; by SCRPHIN; run; proc freq data=reg noprint; table phin_1 / NOCUM out=phinreg; run; data phinreg; set phinreg; rename PERCENT=Registry; drop COUNT; run; data phinfreq; merge phinfreq phinreg; by phin_1; if ABS(PERCENT - REGISTRY) > .5 then Deviance='Greater than +/- 0.5'; label registry="PHIN 1st Digit From Registry (1990-®YR)"; run; proc print data=phinfreq label noobs round; run; proc freq data=phin NLEVELS; table phin_3 phin_5 &TYPE / NOCUM ; format &TYPE $phintype.; run; proc datasets nolist ; delete reg phin phinreg; run; quit; %MEND PHINCHECK;