It is probably going to be easier to combine the files in their original format instead of the transposed format. Perhaps something like this?
data want ;
row+1;
length id date_no 8;
set offenders(in=in1 rename=(offence_date=DATE))
hospital (in=in2 rename=(admit_date=DATE))
;
by id date ;
if in1 then offence_date=date ;
if in2 then admit_date=date ;
date_no + first.date;
if first.id then date_no=1 ;
format date admit_date offence_date yymmdd10. ;
run;
So what does your new FLAG variable represent? Which rows do you want to FLAG for this sample data?
... View more