While Sashikanth is correct that SAS (etc.) cannot store a numeric above ~15 digits safely (most 16 digit numbers, but not all), that's not the entire issue here. (SAS has no true concept of 'integer', all numbers are floating point numbers, hence only storing up to 2**53 at most.)
data a02;
set a01;
id = put(id,$30.);
run;
This incorrectly uses the $30. format, which is a character format. In put
, the format type is driven by the first argument to put, not the resulting type (which is always character - put
generates characters, input
generates numbers). So $30.
would only be appropriate if id
were a character variable. Since it seems like it is a numeric variable, it needs to be:
id2 = put(id,30.);
Note it is id2
on the left hand side - you could not convert a numeric id
to character id
in the same data step, they must have different names.
It's also possible that your number was converted to 1E18 beforehand (such as by Excel, if it passed through there - Excel couldn't store that number precisely either); the data step you posted should have thrown several warnings about character to/from numeric conversion if id
was a numeric variable.