I am attempting to coalesce two data items in PROC SQL and am getting truncation. When I try the same process in a dataset I am also getting truncation, but in a different manner. Consider the following:
data test;
var_a = '111111';
var_b = 12345678;
run;
proc sql;
create table test2 as
select coalesce(input(var_1, 6.), var2) as var3 format = best14.
from test;
quit;
This produces a numeric field with the the value 111111
, which is not what I want. Interestingly if I do it all in one datastep and amend my code as follows:
data test;
format var3 best14.
var_a = '111111';
var_b = 12345678;
var3 = coalesce(input(var_1, 6.), var2);
run;
I get a numeric field output containing 12345678
. What I actually want is an SQL step that will give me a numeric field that contains 11111112345678
.
Can someone please advise on why this truncation is occurring when using the COALESCE function?
Thanks