SAS - how to preserve actual numbers when importing from a csv file with numbers in scientific notation
When I imported a long numeric ids file from a csv file to SAS, I wanted to convert the numbers to text. But these numbers were stored in scientific notation, so when they are converted, the last digits all turn to zeros.
For example 7.3139908E14 wrapped ino 731399080000000 when it should be 731399076376199.
Is there a way to get around this? Ultimately I need to do some deduplication and then export that file as a text file.
Thank!
+3
source to share
1 answer
Say what your data looked like (like a numeric ID in the second position of the CSV):
blah;7313990763761997;blah
You can just read the file, one at a time, and access the input buffer directly (_INFILE_ variable):
filename mycsv "\path\to\mycsv.csv";
data mydata;
infile mycsv;
input;
length idvar $16;
idvar=scan(_infile_,2,";");
run;
This will save the number in plain text if that's all you want to do.
+1
source to share