If you are only interested in readmissions, and there can only be a single readmission per patient, then this will do it in one pass Proc SQL ; Create table readmit as Select adm.ID , adm.Diag , adm.ReadmitID , rad.Diag As ReadmitDiag , case (rad.Diag) When (adm.Diag) Then 'Y' Else 'N' End As Match From admit adm , admit rad Where rad.ID = adm.ReadmitID ; Quit ; However, if you want a more general solution where the possibility of multiple readmissions exists then it would be better to recode the readmission ID to match the original admission, then process the resulting dataset for non matches. If this is the case, I could suggest some code. Richard in Oz
... View more