## Length of decimal importing excel sheet

Frequent Contributor
Posts: 78

# Length of decimal importing excel sheet

[ Edited ]

Hi everyone,

I'm using SAS 9.3. I met a problem while importing excel sheet included a number of 0.0655548562875890.

How should I do to import the entire number into SAS?

If I use BEST32., this number would be read as 0.06555485628758...

It the limit length of decimal place of imported number is 14? If so, how to make it round off to 0.06555485628759?

Here is my code

``````libname xl excel "xxxxxxx.xls" access=readonly header=yes;

proc sql;
create table outfile1 as
select SUBJID, SEX, RACE, AREA
A1 format=30.20,
from xl.'Sheet1\$'n;
select * from outfile1;
quit;

libname xl clear;

data want; set outfile1; format A1 BEST32.; run;``````

Super User
Posts: 9,441

## Re: Length of decimal importing excel sheet

There is a limit to the number of decimal places in SAS.  If your number is bigger than that then you can either read that in as a text string, process it that way, round it in Excel, or use a third party library like python to process it.

Super Contributor
Posts: 278

## Re: Length of decimal importing excel sheet

Hi,

Check out page 10 of the following paper So, Your Data are in Excel!

To explicitly change the type of the imported column(s), you use the dbsastype=() data set option for your Excel source sheet.

Here is another paper worth look at  The Little Engine That Could: Using LIBNAME Engine Options to Enhance Data Transfers Between SAS and...

This way you can preserve the accuracy of your incoming numbers as characters, and perform required manipulations.

SAS Online Documentation - DBSASTYPE= Data Set Option

Hope this helps,

Ahmed

Discussion stats
• 2 replies
• 279 views
• 0 likes
• 3 in conversation