Hi all,
i have two datasets:
1. dataset1 = disease. it contains patients with disease (dx = 1) and no disease (dx = 0)
2. dataset 2 = medication. it contains patients taking medication for the disease (t2D = 1) and those not taking medications(t2D = 0)
i need to get 1. patient with disease and taking med
2. patient with disease not taking med
3. patients without disease taking med
my code is too long,beacuse i had to create new datasets for each category of patients and used inner join. I
/***QUESTION 1**/
/**TAKES EVERY PATIENT WITH THE MEDICATION THAT HAVE DIABETES**/
DATA DXMED; /*1,759,104*/
MERGE T2DMED2 (IN = A) /*1,759,104*/ T2DM2 (IN = B) /**/;
BY PATIENT_ID;
IF A =1 OR B = 1;
RUN;
PROC FREQ DATA = DXMED;
TABLES DX*T2D;
RUN;
**Q2**/
/**PATIENTS TREATED WITHOUT A DIAGNOSIS OF DIABETES**/
DATA MYHUMANA.T2DXXX; /**6,807,243**/ /*DISTINCT PATIENTS WITH NO T2D**/
SET MYHUMANA.T2DX; /*DISTINCT PATIENTS WITH T2D AND NO T2D, 7,436,258**/
IF T2D = 0;
RUN;
/**432,513**/
DATA Q2; /**INNER JOIN**/
MERGE MYHUMANA.T2DXXX (IN = A) /*DISTINCT PATIENTS WITH NO T2D /**7,436,258**/ MYHUMANA.MED(IN = B); /**DISTINCT PATIENTS TAKING ADM**/ /**1,759,104**/
BY PATIENT_ID;
IF A=1 AND B=1;
RUN;
/***CROSS-CHECK WITH ALTERNATE DATA STEP***/
DATA Q2A; /**LEFT JOIN SO ALL PATIENTS TAKING ADM IS IN DATASET Q2A**/ /**1,759,104**/
MERGE MYHUMANA.MED(IN = A) /**1,759,104**/ /*DISTINCT PATIENTS TREATED*/ MYHUMANA.T2DX(IN = B); /**7,436,258**/ /*DISTINCT PATIENTS WITH T2D AND NO T2D**/
BY PATIENT_ID;
IF A=1;
RUN;
/**T2D = 0 = 432,513**/
PROC FREQ DATA = Q2A;
TABLES T2D;
RUN;
/**Q3**/
/**PATIENTS WITH DIABETES AND RECEIVED AN ANTIDIABETIC MEDICATION**/
/**367,471**/
DATA Q3;
MERGE MYHUMANA.T2DXX (IN = A) /**WITH T2D ONLY**/ /**629,015**/ MYHUMANA.MED(IN = B); /**TAKING ADM ONLY**/ /**1,759,104**/
BY PATIENT_ID;
IF A=1 AND B=1;
RUN;
s there an efficent way i can do this please? THANK YOU