Desktop productivity for business analysts and programmers

Reading Excel file with large decimal Places

Reply
Contributor
Posts: 29

Reading Excel file with large decimal Places

Hi All , 

 

  I am trying to read an excel file into SAS with character variables having more than 10 decimal places and some of the cells has exponential values like 4.658535495689E-2, but after the excel is read i can see the decimal values in dataset only till 6 or 7th position only, but i want the complete decimal value to be displayed in the SAS dataset.There is no issue with the Length also, as some of the values are getting read completely ,but not all. Any options/methods to read the complete decimal values. Tried with inflie , libname statement also but could not retrieve all the decimal values from excel.

Some of the values present in excel are as below.

 

24.550898203592801
22.793831799922199
13.495276653171301
4.658535495689E-2
4.116260242164E-2
7.1999999999999995E-2

 

 

Below is the sample code used to retrieved.

proc import datafile="&path/&fname.xlsx"
dbms = xlsx out= data_ replace;
datarow=1;
getnames = yes;
run;

 

Any suggestions how to retrieve the complete decimal values from excel to SAS dataset.

Esteemed Advisor
Posts: 6,646

Re: Reading Excel file with large decimal Places

Be aware that SAS works with 8-byte real numbers, which means that the precision is restricted to around 15 decimal digits.

 

Assign a long enough format like best32. so you can see all digits present in SAS.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Grand Advisor
Posts: 10,210

Re: Reading Excel file with large decimal Places

Run Proc Contents on the resulting data set to see the format. Likely  it will be BEST8. The values are likely therr, barring more than 15 decimals just not displaying. If you really care to see that many decimals change the formats to something you preferr like BEST32. of F24.16 or such.

Ask a Question
Discussion stats
  • 2 replies
  • 353 views
  • 0 likes
  • 3 in conversation