I have encountered a case where I am 100% sure the syntax is correct for merging datasets, but the result includes rows that are separate (while you expect them to see on the same row). This is likely because string variables have different length of trailing blanks. I recommend using STRIP function on IDs before the merge:
input string $char8.;
kaz = strip(string);
x y z
proc print data=lengthn;
This situation can occur easily, but it does not generate error messages. This is a serious problem.