/******************************************************************************************** **** Program name: Macro to identify new users of antihypertensives **** **** Author: Raj Desai ********************************************************************************************/ libname htn "F:\"; libname raj "E:\raj_desai\ICPE"; libname rxnorm 'E:\Resources\RXNORM'; libname a 'E:\raj_desai'; libname red 'E:\Resources\Redbook'; /************** Step 1. Identify the RXCUI's and NDC's for antihypertensives**********************/ data rxcui_htn; set rxnorm.antihtn_rxcui_classes; where (single_class_var contains 'ACEI') or (single_class_var contains 'ARB') or (single_class_var contains 'BB') or (single_class_var contains 'THIAZIDE_DIURETIC') or (single_class_var contains 'DHP_CCB') or (single_class_var contains 'NONDHP_CCB') or (single_class_var contains 'ALPHA2_AGONIST') or (single_class_var contains 'ALPHA1_BLOCKER') or (single_class_var contains 'ALDO_ANTAGONIST') or (single_class_var contains 'LOOP_DIURETIC'); run; data ndc_htn; set rxnorm.antihtn_ndc_classes; where (single_class_var contains 'ACEI') or (single_class_var contains 'ARB') or (single_class_var contains 'BB') or (single_class_var contains 'THIAZIDE_DIURETIC') or (single_class_var contains 'DHP_CCB') or (single_class_var contains 'NONDHP_CCB') or (single_class_var contains 'ALPHA2_AGONIST') or (single_class_var contains 'ALPHA1_BLOCKER') or (single_class_var contains 'ALDO_ANTAGONIST') or (single_class_var contains 'LOOP_DIURETIC'); run; /* Note: You can also identify RXCUI's for antihypertensives from https://www.nlm.nih.gov/research/umls/rxnorm/index.html*/ /**********************Step 2. Identify patients who have linked Medicare claims data****************************/ data overlap_ce; set a.ENR_OVERLAP_EHR_MCARE(where=((end - start >= 365))); run; /*distinct patid*/ proc sort data=overlap_ce nodupkey out=uniq_pat; by patid; run; /*NOTE: The data set WORK.UNIQ_PAT include patients with linked claims data*/ /* Note: the dataset a.ENR_OVERLAP_EHR_MCARE was created by running the Magik macro*/ /******************************************Creating the true new user macro**************************************/ options mprint; %macro newuser(drug); /*****************Step 3A: Identify patients with atleast one antihypertensive prescription********************/ proc sql; create table major_rx1_&drug. as select * from htn.htn_rx where RXNORM_CUI in (select distinct RXCUI from rxcui_&drug.) and patid in (select distinct patid from overlap_ce); create table major_rx_&drug. as select * from major_rx1_&drug. where RX_BASIS='01' /*01 indicates*/; quit; /*****************Step 3B: Flag the first antihypertensive prescription date i.e., index date********************/ proc sql; create table step1_&drug. as select distinct patid, min(rx_order_date) as firstever_rx_date format date9. from major_rx_&drug. group by patid; quit; /*****************Step 4: Require patients to have atleast 365 days of lookback period********************/ proc sql; create table step2_&drug. as select a.*, b.start, b.end from step1_&drug. a inner join a.ENR_OVERLAP_EHR_MCARE b on a.patid=b.patid where b.start <= (a.firstever_rx_date - 365) and a.firstever_rx_date <= b.end ; quit; /**************** Step 5. Check if any dispensing of antihypertensives in the lookback period************************/ proc sql; create table step3_&drug. as select a.*, b.* from step2_&drug. a inner join htn.mcare_htn_dispense b on a.patid=b.patid WHERE b.ndc in (select distinct ndcnum from ndc_&drug.) and (a.firstever_rx_date-365) <= b.dispense_date < a.firstever_rx_date ; quit; proc sql; create table final_&drug. as select distinct patid from step3_&drug.; quit; /*dataset called final_&drug. has a list of patient id's who are actually new users of antihypertensives*/ %mend; %newuser(htn) /******************************************************************************************** **** Program name: Macro to identify new users of individual antihypertensive drug class **** **** Author: Raj Desai ********************************************************************************************/ /************** Step 1. Identify the RXCUI's and NDC's for antihypertensives**********************/ data rxcui_htn(rename=(single_class_var=class)); set rxnorm.antihtn_rxcui_classes; run; data ndc_htn (rename=(single_class_var=class)); set rxnorm.antihtn_ndc_classes; run; /* Note: (1) The dataset antihtn_rxcui_classes and antihtn_ndc_classes has information on the NDCs and RXCUIs of antihypertensives. To obtained the dataset contact Steven Smith (2) You can also identify RXCUI's for antihypertensives from https://www.nlm.nih.gov/research/umls/rxnorm/index.html*/ /**********************Step 2. Identify patients who have linked Medicare claims data****************************/ /*distinct patid*/ proc sort data=overlap_ce nodupkey out=uniq_pat; by patid; run; /*NOTE: The data set WORK.UNIQ_PAT include patients with linked claims data*/ /*************************************Creating the true new users of CCBs*************************/ options mprint; %macro newuser(drug,class); /*****************Step 3A: Identify patients with atleast one antihypertensive prescription********************/ proc sql; create table major_rx1_&drug. as select * from htn.htn_rx where RXNORM_CUI in (select distinct RXCUI from rxcui_&drug.) and patid in (select distinct patid from overlap_ce); create table major_rx_&drug. as select * from major_rx1_&drug. where RX_BASIS='01'; quit; data class_&drug.(rename=(RXCUI=RXNORM_CUI)); set rxcui_&drug.(keep=RXCUI class); run; proc sort data=major_rx_&drug. out=major_rx_2&drug.; by RXNORM_CUI; run; proc sort data=class_&drug.; by RXNORM_CUI; run; data names_rx_&drug.; merge major_rx_2&drug.(in=a) class_&drug.(in=b); by RXNORM_CUI; if a; run; /*****************Step 3B: Scan records for CCB prescription********************/ %macro major_htn_rxs(classes); data names_rx1_&drug.; set names_rx_&drug.; if %do i = 1 %to %sysfunc(countw(&classes)); find(class,"%scan(&classes,&i)",'i') %if &i < %sysfunc(countw(&classes)) %then %do; or %end; %end; ; run; %mend; %major_htn_rxs(classes=&class.); /*****************Step 4: Flag the first CCB prescription date i.e., index date********************/ proc sql; create table step3_&drug.&class. as select distinct patid, min(rx_order_date) as firstever_rx_date format date9. from names_rx1_&drug. group by patid; quit; /*****************Step 5: Require patients to have atleast 365 days of lookback period********************/ proc sql; create table step4_&drug.&class. as select a.*, b.start, b.end from step3_&drug.&class. a inner join a.ENR_OVERLAP_EHR_MCARE b on a.patid=b.patid where b.start <= (a.firstever_rx_date - 365) and a.firstever_rx_date <= b.end ; quit; /********************** Step 6. Check if any dispensing of CCBs in the lookback period************************/ proc sql; create table step5_&drug.&class. as select a.*, b.* from step4_&drug.&class. a inner join htn.mcare_htn_dispense b on a.patid=b.patid WHERE b.ndc in (select distinct ndcnum from ndc_&drug.) and (a.firstever_rx_date-365) <= b.dispense_date < a.firstever_rx_date ; quit; proc sql; create table step5a_&drug.&class. as select a.*, b.class from step5_&drug.&class. a inner join ndc_&drug. b on a.ndc =b.ndcnum; quit; %macro major_rx_rxs(classes); data step5b_&drug.&class.; set step5a_&drug.&class.; if %do i = 1 %to %sysfunc(countw(&classes)); find(class,"%scan(&classes,&i)",'i') %if &i < %sysfunc(countw(&classes)) %then %do; or %end; %end; ; run; %mend; %major_rx_rxs(classes=&class.);