It really helps to provide some data. How do we know what the discharge date of your index variable is? Or the admission date of the Read_flag2? Are they even SAS date values, character or some other numeric that looks vaguely date like.
You can use the instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712 to create data step code of your All.New_reflag dataset so we can test data against it. But you may still need to tell use how to identify DISD and ADMD.
... View more