Hi,
I am trying to import an excel(.xls,.xlsx,csv) one of the columns has more than 20 length long values, and after the import the data is displayed as
Values on the Excel:
100000000882336
Displayed value:
1E14
1.0000001E14
can you please suggest?
Please note you cannot store accurately more than about 16 digits in a SAS numeric variable, so you need to import your column as a character variable. In Excel define your column as a Text column then try re-importing.
Common discussion related to computer precision and storage and display of values.
Are these values actually numbers used in arithemetic or something like account numbers? If the later then import them to character.
The variable has a format which may currently be BEST12. which is the default for some things. You may try changing that to BEST20. and see if that helps.
In a data step format the variable with Z20.
syntax: format variable_name Z20.;
Please note you cannot store accurately more than about 16 digits in a SAS numeric variable, so you need to import your column as a character variable. In Excel define your column as a Text column then try re-importing.
Hi ,
Thank you !!!
I was able to do it by using the below,
libname myxls xlsx "D:/.....xlsx";
data csvdata(Drop=Len);
Length newvar $50.;
set myxls.sheet1;
newvar=put(ID, 16.);
Len=length(newvar);
Rename Newvar=ID;
run;
Good to see you've got a solution, but you shouldn't have to do it in code. If changing the column to text in Excel doesn't work then use the Text to Columns feature by highlighting the ID column then select the Text to Columns option on the Data menu.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.