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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.