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;
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:
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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.