/***************************************************************************** PROGRAM: AMI_94_15.SAS TITLE: Defining the Acute Myocardial Infarction Cohort CREATED BY: Interdisciplinary Chronic Disease Collaboration (ICDC)/ Alberta Kidney Disease Network (AKDN), August 2012 SOFTWARE: SAS 9.3 ====================================================================== Updated by Zhihai in Mar, 2016. 1) Update the variable names, so the variable names will be the same as the raw data received from Alberta Health Service. ====================================================================== TERMS OF USE: This code was created by the ICDC/AKDN for its own use. Please be aware that the ICDC/AKDN DOES NOT: 1) Provide any guarantees about this code 2) Commit to the availability of any updates to the code 3) Support any implementation outside of the ICDC/AKDN Please use this code for information purposes only. ====================================================================== Goal: Identify people in the Alberta Health and Wellness (AHW) administrative data from April 1, 1994 to March 31, 2015 with an acute myocardial infarction (AMI). This will form a cohort of patients with AMI as a disease condition. ICDC/AKDN Definition for AMI DATASETS: 1. Hospitalization Discharge Abstract Database (DAD), Apr. 1994 - Mar. 2015. Most responsible diagnosis (type='M') or where AMI was a post-admission diagnosis (type='2') CODES: AMI: 410 (ICD9) AND I21, I22 (ICD10) HOSPITALIZATION TYPE: Most responsible diagnosis (type='M') or where AMI was a post-admission diagnosis (type='2') DATES TO BE USED: All available data. ONSET DATE: The date of first AMI occurrence between April 1, 1994 and March 31, 2015 will be used as the 'onset' date. WASH-OUT PERIOD: There will be a wash-out period of at least 3 years. Therefore, if the first AMI (by definition) occurs on or after April 1, 1997, AMI will be considered an incident case. If the first AMI (by definition) occurs between April 1, 1994 and March 31, 1997, there will not be a wash- out period of at least 3 years available. In this case, AMI will be considered prevalent. USAGE NOTES (for this program): The AMI_94_15_cohort dataset includes the patients with an AMI identified as the most responsible diagnosis or as an in-hospital complication. This dataset can be used to identify a cohort of patients with AMI as a disease condition. Only the first incident AMI is included. AMI episodes following the first (incident event) are not included. The dataset includes both adults and non-adults at the time of first AMI. PHN is the unique identifier used to link the administrative data. ******************************************************************************/ option threads=yes nofmterr nonumber mlogic helpbrowser=sas; * HELPBROWSER=SAS sets the SAS browser to default in the 64-bit OS --; * Location of the AHW administrative datasets (Hospitalizations) --; libname ahw 'G:\IDENTIFIED\AHW\EXTRACTION_1994_2015\DATA\CleanDataCombined_2013_2015\DataCombined_2013_2015'; * Location to store the AMI_94_11_cohort dataset --; libname ami 'G:\IDENTIFIED\AHW\EXTRACTION_1994_2015\DATA\DERIVED_DATA\AHW_AMI\DATA'; * Location of the demographics dataset created by the ICDC/AKDN. Includes information on gender, and dates of birth, death, and out-migration from Alberta --; libname demog 'G:\IDENTIFIED\AHW\EXTRACTION_1994_2015\DATA\DERIVED_DATA\AHW_DEMOGRAPHICS\DEMOGRAPHICS\DATA'; *********************************; * MACROS USED IN THIS PROGRAM -- ; *********************************; * MACRO for defining Fiscal Year from April 1994 - March 2015 --; %macro fy(in_t=,out_t=,date=); data &out_t; set &in_t; if not missing(&date) then do; if &date<='31MAR1994'd then FY='----/1994'; if '01APR1994'd<=&date<='31MAR1995'd then FY='1994/1995'; if '01APR1995'd<=&date<='31MAR1996'd then FY='1995/1996'; if '01APR1996'd<=&date<='31MAR1997'd then FY='1996/1997'; if '01APR1997'd<=&date<='31MAR1998'd then FY='1997/1998'; if '01APR1998'd<=&date<='31MAR1999'd then FY='1998/1999'; if '01APR1999'd<=&date<='31MAR2000'd then FY='1999/2000'; if '01APR2000'd<=&date<='31MAR2001'd then FY='2000/2001'; if '01APR2001'd<=&date<='31MAR2002'd then FY='2001/2002'; if '01APR2002'd<=&date<='31MAR2003'd then FY='2002/2003'; if '01APR2003'd<=&date<='31MAR2004'd then FY='2003/2004'; if '01APR2004'd<=&date<='31MAR2005'd then FY='2004/2005'; if '01APR2005'd<=&date<='31MAR2006'd then FY='2005/2006'; if '01APR2006'd<=&date<='31MAR2007'd then FY='2006/2007'; if '01APR2007'd<=&date<='31MAR2008'd then FY='2007/2008'; if '01APR2008'd<=&date<='31MAR2009'd then FY='2008/2009'; if '01APR2009'd<=&date<='31MAR2010'd then FY='2009/2010'; if '01APR2010'd<=&date<='31MAR2011'd then FY='2010/2011'; if '01APR2011'd<=&date<='31MAR2012'd then FY='2011/2012'; if '01APR2012'd<=&date<='31MAR2013'd then FY='2012/2013'; if '01APR2013'd<=&date<='31MAR2014'd then FY='2013/2014'; if '01APR2014'd<=&date<='31MAR2015'd then FY='2014/2015'; if '01APR2015'd<=&date then FY='2015/----'; end; COUNT=1; run; %mend fy; * MACRO for sorting by &var--; %macro srt(in_t=,out_t=,var=); proc sort data=&in_t out=&out_t; by &var; run; %mend srt; * MACRO to delete records in datasets occuring before dob and after death or outmigration --; * This macro uses the demographics dataset and SRT macro, defines the AGE variable, and produces * frequencies of records to be deleted. It also creates the &out_t2 dataset with the records deleted --; %macro demogcheck(in_t=,out_t1=,out_t2=,sourcedate=); data &out_t1; merge &in_t (in=in1) demog.ahw_demographics_2015(in=in2); by phn; if in1; age=(&sourcedate-PERS_DOB)/365.25; if (PERS_DOB^=. and PERS_DOB>&sourcedate) or PERS_DOB=. then dobdelete=1; if death_date^=. and death_date<&sourcedate then deathdelete=1; if out_migrate_date^=. and out_migrate_date<&sourcedate then outdelete=1; if dobdelete=1 | deathdelete=1 | outdelete=1 then rec_delete=1; run; proc freq data=&out_t1; table dobdelete*deathdelete*outdelete*rec_delete/list missing; run; %srt(in_t=&out_t1,out_t=&out_t1,var=phn); data &out_t2; set &out_t1; if rec_delete=1 then delete; run; %mend demogcheck; * MACRO to count number of subjects --; %macro subjects(ds=); proc sort data=&ds out=subj_&ds nodupkey; by phn; run; %mend subjects; * MACRO to extract codes for ICD9 dataset --; * The ICD9 codes from the hospitalizations database are available from 3 datasets covering * the fiscal years 1994-1997, 1997-1999, and 1999-2002. There are 16 fields for ICD9 * diagnosis codes.; %macro hosp_icd9(in_t=,out_t1=,out_t2=); data &out_t1; set &in_t(keep=PHN START_DATE END_DATE SEPI_DX_MR_ICD9CM SEPI_DX_OTH_ICD9CM_1-SEPI_DX_OTH_ICD9CM_15 SEPIMRSP_DXTYP_HMRIDXTYP SEPI_DXTYP_OTH_HMRI_1-SEPI_DXTYP_OTH_HMRI_15); if substr(SEPI_DX_MR_ICD9CM,1,3) in ('410') then do; AMI_MR='1'; CODE=SEPI_DX_MR_ICD9CM; TYPE='M'; end; ARRAY diag_icd9_ (*) $ SEPI_DX_OTH_ICD9CM_1-SEPI_DX_OTH_ICD9CM_15 ; ARRAY type_icd9_ (*) $ SEPI_DXTYP_OTH_HMRI_1-SEPI_DXTYP_OTH_HMRI_15; ARRAY code_icd9_ (*) $ CODE1-CODE15; do i=1 to DIM(diag_icd9_); if (substr(diag_icd9_(i),1,3) in ('410')) and (substr(type_icd9_(i),1,1)='2') then do; AMI_OTH='1'; if CODE=' ' then CODE=diag_icd9_(i); code_icd9_(i)=diag_icd9_(i); end; end; if AMI_MR='1' or AMI_OTH='1' then AMI=1; if missing(TYPE) and AMI=1 then TYPE='2'; drop i; run; data &out_t2; retain PHN START_DATE END_DATE AMI_MR AMI_OTH AMI TYPE CODE; LENGTH CODE $7; set &out_t1; if AMI=1; keep PHN START_DATE END_DATE AMI_MR AMI_OTH AMI TYPE CODE; run; %mend hosp_icd9; * MACRO to extract codes for ICD10 dataset --; * The ICD10 codes from the hospitalizations database are available from 1 dataset covering * the fiscal years 2002-2009. There are 25 fields for ICD10 diagnosis codes.; %macro hosp_icd10(in_t=,out_t1=,out_t2=); data &out_t1; set &in_t(keep=PHN START_DATE END_DATE DX1-DX25 TYPE1-TYPE25); if substr(DX1,1,3) in ('I21','I22') then do; AMI_MR='1'; CODE=DX1; TYPE='M'; end; ARRAY diag_icd10_ (*) $ DX2-DX25; ARRAY type_icd10_ (*) $ TYPE2-TYPE25; ARRAY code_icd10_ (*) $ CODE2-CODE25; do i=1 to DIM(diag_icd10_); if ((substr(diag_icd10_(i),1,3) in ('I21','I22')) and (substr(type_icd10_(i),1,1)='2')) then do; AMI_OTH='1'; if CODE=' ' then CODE=diag_icd10_(i); code_icd10_(i)=diag_icd10_(i); end; end; if AMI_MR='1' or AMI_OTH='1' then AMI=1; if missing(TYPE) and AMI=1 then TYPE='2'; drop i; run; data &out_t2; retain PHN START_DATE END_DATE AMI_MR AMI_OTH AMI TYPE CODE; set &out_t1; if AMI=1; keep PHN START_DATE END_DATE AMI_MR AMI_OTH AMI TYPE CODE; run; %mend hosp_icd10; **********************************************; * Identify AMI from the hospitalization files ; **********************************************; * 1) Create datasets with all hospitalizations containing the relevant codes --; %hosp_icd9(in_t=ahw.hosp_94_97,out_t1=ami._hosp_94_97,out_t2=ami.hosp_94_97); %hosp_icd9(in_t=ahw.hosp_97_99,out_t1=ami._hosp_97_99,out_t2=ami.hosp_97_99); %hosp_icd9(in_t=ahw.hosp_99_02,out_t1=ami._hosp_99_02,out_t2=ami.hosp_99_02); %hosp_icd10(in_t=ahw.hosp_02_15,out_t1=ami._hosp_02_15,out_t2=ami.hosp_02_15); * 2) Combine all 4 data sources and sort by phn/start/end date --; data ami1; set ami.hosp_94_97 ami.hosp_97_99 ami.hosp_99_02 ami.hosp_02_15; run; proc sort; by phn start_date end_date; run; * Check patient numbers --; %subjects(ds=ami1) * 3) Save dataset with all hospitalizations --; data ami.AMI_94_15_ALL; retain PHN START_DATE END_DATE AMI_MR AMI_OTH AMI TYPE CODE; set ami1; run; * 4) Delete hospitalizations after death date/out-migration date or before DOB --; %demogcheck(in_t=ami.ami_94_15_all, out_t1=ami2, out_t2=ami3, sourcedate=start_date); * 5) Take first record per patient, define prevalence and incidence, and rename variables --; data ami4; retain PHN AMI START_DATE TYPE CODE; set ami3(drop=death death_date out_migrate out_migrate_date dobdelete deathdelete outdelete rec_delete PERS_GENDER_CODE PERS_DOB aboriginal ami_mr ami_oth); by phn start_date end_date; if first.phn; if start_date<'01APR1997'd then CASE='PREVALENT'; if start_date>='01APR1997'd or age<3 then CASE='INCIDENT'; if age>=18 then ADULT=1; else ADULT=0; rename start_date=AMI_DATE; drop end_date; label phn=' ' start_date=' '; run; proc freq data=ami4; table adult; run; * 6) Save AMI cohort --; data ami.AMI_94_15_COHORT(drop=code) AMI_94_15_COHORT; set ami4(drop=age adult); run; ****************************************************************; * DESCRIPTIVE STATISTICS FOR THE AMI COHORT, AMI_94_15_COHORT --; ****************************************************************; * Add Fiscal Year --; %fy(in_t=AMI_94_15_cohort,out_t=test,date=AMI_date) * Descriptives --; ods rtf file="G:\IDENTIFIED\AHW\EXTRACTION_1994_2015\DATA\DERIVED_DATA\AHW_AMI\OUTPUT\AMI_cohortsummary_2015.rtf" bodytitle; title1 "PROC CONTENTS: AMI_94_15_COHORT"; proc contents data=ami.ami_94_15_cohort varnum; run; title1; title1 "Frequency of Subjects who are Adults (>=18 yrs) at time of First MI (by Defn)"; proc freq data=ami4; table ADULT; run; title1; title1 "Frequency of Prevalent and Incident AMI (by Defn)"; proc freq data=test; table Case/missing; run; title1; title1 "Frequency of Prevalent and Incident AMI (by Defn) by Fiscal Year"; proc freq data=test; table Case*fy/list missing; run; title1; title1 "Frequency: First AMI (by Defn) by Fiscal Year"; proc freq data=test; table fy/missing out=testa; run; title1; title1 "Frequency: Prevalent AMI (by Defn) by Fiscal Year"; proc freq data=test(where=(case='PREVALENT')); table fy*case/missing; run; title1; title1 "Frequency: Incident AMI (by Defn) by Fiscal Year"; proc freq data=test(where=(case='INCIDENT')); table fy*case/missing; run; title1; title1 "Frequency: First AMI (by Defn)- Most Responsible or Post-admission Complication"; proc freq data=test; table type/missing; run; title1; title1 "Frequency: First AMI (by Defn)- Most Responsible or Post-admission Complication by Fiscal Year"; proc freq data=test; table fy*type/missing; run; title1; title1 "Frequency: First AMI (by Defn)- ICD Code"; proc freq data=test; table code/missing; run; title1; title1 "Frequency: First AMI (by Defn)- ICD Code by Most Responsible or Post-admission Complication"; proc freq data=test; table code*type/missing; run; title1; title1 "Frequency: First AMI (by Defn)- ICD Code by Fiscal Year"; proc freq data=test; table code*fy/missing; run; title1; * Create Graph- AMI (by Defn) by Fiscal Year --; title1 "Graph: First AMI (by Defn) by Fiscal Year"; proc gplot data=testa; plot count*fy/ vaxis=0 TO 5400 BY 200; symbol i=join v=circle c=black; label count="First AMI (by Defn)"; label fy="Fiscal Year of First AMI (by Defn)"; run; quit; ods rtf close; *******************; * END OF PROGRAM --; *******************;