BookmarkSubscribeRSS Feed
JohnChen_TW
Quartz | Level 8

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;

 

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Try the advice in this thread:

https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-Excel-file-with-large-decimal-Places/m-p...

AhmedAl_Attar
Ammonite | Level 13

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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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