The array code (posted below) that I used below did not produce an error, but I am trying to determine where I went wrong in altering the code because the results of the dup variable did not come out as desired (posted below) so I must have not altered the code correctly. What I am trying to gather is how many duplicate date pairs (for example does admit 1 and discharge 1 = admit 2 and discharge 2, does admit 2 and discharge 2 = admit 3 and discharge 3 ex). If admit 1 and discharge 1 was the same as admit 2 and discharge 2, then I would expect my dup variable calculated in the array to = 1. If admit 1 and discharge 1 were the same as admit 2 and discharge 2 which was also the same as admit 3 and discharge 3 then I would expect my dup variable to = 2. I have posted a small part of the output and a column of what I would want the dup variable to be. Code: data icu1dup; dup = 0; set icu1; array admit {*} ICU_AdmitDate ICU_AdmitDate2 ICU_AdmitDate3 ICU_AdmitDate4 ICU_AdmitDate5 ICU_AdmitDate6; array discharge {*}ICU_DischargeDate ICU_DischargeDate2 ICU_DischargeDate3 ICU_DischargeDate4 ICU_DischargeDate5 ICU_DischargeDate6; do i = 2 to dim (admit); if admit(i-1)=admit(i) and discharge(i-1)=discharge(i) then do; dup = i + 1; leave; end; end; run; Log: NOTE: There were 24900 observations read from the data set WORK.ICU. NOTE: The data set WORK.ICU1 has 23556 observations and 264 variables. NOTE: DATA statement used (Total process time): real time 0.96 seconds cpu time 0.24 seconds 15 data icu1dup; 16 dup = 0; 17 set icu1; 18 array admit {*} ICU_AdmitDate ICU_AdmitDate2 ICU_AdmitDate3 ICU_AdmitDate4 ICU_AdmitDate5 18 ! ICU_AdmitDate6; 19 array discharge {*}ICU_DischargeDate ICU_DischargeDate2 ICU_DischargeDate3 19 ! ICU_DischargeDate4 ICU_DischargeDate5 ICU_DischargeDate6; 20 do i = 2 to dim (admit); 21 if admit(i-1)=admit(i) and discharge(i-1)=discharge(i) then 22 do; 23 dup = i + 1; 24 leave; 25 end; 26 end; 27 run; NOTE: There were 23556 observations read from the data set WORK.ICU1. NOTE: The data set WORK.ICU1DUP has 23556 observations and 266 variables. NOTE: DATA statement used (Total process time): real time 0.70 seconds cpu time 0.32 seconds Output (small portion) Obs ICU_AdmitDate ICU_DischargeDate ICU_AdmitDate2 ICU_DischargeDate2 ICU_AdmitDate3 ICU_DischargeDate3 ICU_AdmitDate4 ICU_DischargeDate4 ICU_AdmitDate5 ICU_DischargeDate5 ICU_AdmitDate6 ICU_DischargeDate6 dup what I would expect 127 7-Jul-20 8-Jul-20 08-Jul-20 08-Jul-20 08-Jul-20 09-Jul-20 09-Jul-20 10-Jul-20 . . . . 7 0 131 6-Oct-21 6-Oct-21 06-Oct-21 11-Oct-21 . . . . . . . . 5 0 132 23-Nov-20 23-Nov-20 23-Nov-20 23-Nov-20 23-Nov-20 23-Nov-20 23-Nov-20 23-Nov-20 23-Nov-20 23-Nov-20 23-Nov-20 24-Nov-20 3 6 134 23-Jul-20 23-Jul-20 . 23-Jul-20 . 24-Jul-20 . . . . . . 6 0
... View more