11-24-2017 04:31 AM - edited 11-24-2017 04:36 AM
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;
11-24-2017 04:50 AM
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:
11-24-2017 07:30 AM
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.
Hope this helps,