Order of operations in MERGE affect length/values of variables with the same name.
Please see this code:
data example1;
input id text1 :$15.;
datalines;
1 abcdefghijklmn
2 somethingelse
;
data example2;
input id text1:$5. word $;
datalines;
1 abcde zzzz
2 some yyyy
;
data merge1;
merge example1
example2
;
by id;
run;
data merge2;
merge example2
example1
;
by id;
run;
proc contents data=merge1;
run;
proc contents data=merge2;
run;
The first data set encountered in a Merge statement sets the LENGTH of common named variables.
The last encountered data set in a Merge statement sets the Value of common named variables.
So in Merge1 , the Length of the Text1 variable is 15 but the value comes from example2.
In Merge2 the length of Text1 comes from Example2 so the value from Example1 gets truncated because it cannot fit.
One fix might be to set the length of the variable before the Merge statement.
data merge3;
length text1 $ 15;
merge example2
example1
;
by id;
run;