DATA Step, Macro, Functions and more

SAS unable to read long value numeric( displaying as exponential)

Accepted Solution Solved
Reply
Contributor
Posts: 66
Accepted Solution

SAS unable to read long value numeric( displaying as exponential)

Hi,

 

I am trying to import an excel(.xls,.xlsx,csv) one of the columns has more than 20 length long values, and after the import the data is displayed as

Values on the Excel:

100000000882336

 

Displayed value:

1E14
1.0000001E14

 

can you please suggest?

 


Accepted Solutions
Solution
‎05-26-2016 05:49 PM
Super User
Posts: 3,110

Re: SAS unable to read long value numeric( displaying as exponential)

Please note you cannot store accurately more than about 16 digits in a SAS numeric variable, so you need to import your column as a character variable. In Excel define your column as a Text column then try re-importing.

View solution in original post


All Replies
Super User
Posts: 10,516

Re: SAS unable to read long value numeric( displaying as exponential)

Common discussion related to computer precision and storage and display of values.

 

Are these values actually numbers used in arithemetic or something like account numbers? If the later then import them to character.

 

The variable has a format which may currently be BEST12. which is the default for some things. You may try changing that to BEST20. and see if that helps.

Occasional Learner
Posts: 1

Re: SAS unable to read long value numeric( displaying as exponential)

In a data step format the variable with Z20.

 

syntax:  format variable_name Z20.;

Solution
‎05-26-2016 05:49 PM
Super User
Posts: 3,110

Re: SAS unable to read long value numeric( displaying as exponential)

Please note you cannot store accurately more than about 16 digits in a SAS numeric variable, so you need to import your column as a character variable. In Excel define your column as a Text column then try re-importing.

Contributor
Posts: 66

Re: SAS unable to read long value numeric( displaying as exponential)

Hi ,

 

Thank you !!!

 

I was able to do it by using the below,

libname myxls xlsx "D:/.....xlsx";

data csvdata(Drop=Len);

Length newvar $50.;

set myxls.sheet1; 

newvar=put(ID, 16.);

Len=length(newvar);

Rename Newvar=ID; 

run;

 

 

 

Super User
Posts: 3,110

Re: SAS unable to read long value numeric( displaying as exponential)

Good to see you've got a solution, but you shouldn't have to do it in code. If changing the column to text in Excel doesn't work then use the Text to Columns feature by highlighting the ID column then select the Text to Columns option on the Data menu.  

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 401 views
  • 0 likes
  • 4 in conversation