Hi @luca87,
I think the truncation is just due to the insufficiently defined length of variable ONE:
@luca87 wrote:
data test;
length
ONE $40.
TWO $5.
three $10.
four $10.
;
infile test ;
input;
ONE =ksubstr(_infile_,1 , 41 );
TWO =ksubstr(_INFILE_,41 , 5 );
three =ksubstr(_INFILE_,46 , 10 );
four =ksubstr(_INFILE_,56 , 10 );
run;
With length $41 (no periods needed after length specifications) variable ONE should contain the missing character.
EDIT: This will also append an additional character to the values of ONE in the first three observations, though, causing an overlap with variable TWO. To avoid this overlap, use 40, not 41, in the third argument of the KSUBSTR function:
ONE=ksubstr(_infile_, 1, 40);
EDIT 2: To be on the safe side in case of more or longer multi-byte characters to be stored in variable ONE, just increase the defined length of the variable further (as this length is measured in bytes), but keep the 40 (i.e., 40 characters) in the KSUBSTR argument.
... View more