SAS data merge problem

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:

data lengthn;
input string $char8.;

kaz = strip(string);
datalines;
abcd
abcd
abcd
abcdefgh
x y z
;

proc print data=lengthn;
run;

This situation can occur easily, but it does not generate error messages.  This is a serious problem.

ORIGINAL REFERENCE:
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002295689.htm

Leave a Reply