user1318306
user1318306

Reputation: 31

SAS - how to preserve actual numbers when importing from a csv file with numbers in scientific notation

When I imported a file with long numeric IDs from a csv file into SAS, I wanted to convert the numbers into text. But these numbers were stored in scientific notation, so when they convert, the last digits all turned into zeros.

For example, 7.3139908E14 turned ino 731399080000000, when it should be 731399076376199.

Is there anyway to work around this? Ultimately I need to do some deduping and then export this file out as a text file.

Thanks!

Upvotes: 3

Views: 10070

Answers (1)

DavB
DavB

Reputation: 1696

Say your data looked like (i.e. numeric ID in second CSV position):

blah;7313990763761997;blah

You could do a simple read of the file, line by line and access the input buffer directly (the _INFILE_ variable):

filename mycsv "\path\to\mycsv.csv";

data mydata;
  infile mycsv;
  input;
  length idvar $16;
  idvar=scan(_infile_,2,";");
run;

This will preserve the number in text format, if that's all you wish to do.

Upvotes: 1

Related Questions