Hi SAS Experts Normally I would have one line per patient per admission however in this case it is to complicated and instead I have multiples lines per patient per admission. I my normal case I would use an array and then define my diagnosis variables (please see example code below). data indlagte_main; set indlagte_main; addiction=0; alcohol=0; array x{*} diagindH1-diagindH2 diagindB1-diagindB10; do i=1 to dim(x); if substr(misdiag{i},1,3) in ('DF1') then do;addiction=1; end; if substr(misdiag{i},1,4) in ('DF10') then do; alcohol=1; end; end; run; This is what I have now Record_id admissionnumber Admission date Discharge date date of diagnosis diagnosis 1 1 01-01-2010 01-02-2010 02-01-2010 df200 1 1 01-01-2010 01-02-2010 02-03-2010 df100 1 2 03-03-2010 31-03-2010 04-03-2010 df147 1 2 03-03-2010 31-03-2010 04-03-2010 df200 This is what I want. Addiction and alcohol definitions should be the same as in the above array. Record_id admissionnumber Admission date Discharge date Addiction Alcohol 1 1 01-01-2010 01-02-2010 1 1 1 2 03-03-2010 31-03-2010 1 0 I hope this makes sence. Kind regards from Solvej
... View more