There is a SAS limit to the how large a numeric can be and still retain exact integer representation. (Based on binary limits of mantissa and exponent features in double precision floating point values)
From the "SAS Companion for Windows"
Significant Digits and Largest Integer by Length for SAS Variables under Windows
Length Largest
in Integer Significant
Bytes Represented Exponential Digits
Exactly Notation Retained
------ ----------------------- ----------- -----------
3 8,192 213 3
4 2,097,152 221 6
5 536,870,912 229 8
6 137,438,953,472 237 11
7 35,184,372,088,832 245 13
8 9,007,199,254,740,992 253 15
There is no option for directly specifying the column formats with the IMPORT
Procedure.
You can recall the DATA Step source code that the procedure creates and modify that.
From the documentation File "Format-Specific Reference for the IMPORT and EXPORT Procedures" Delimited Files
Processing Delimited Files in SAS
When you use PROC IMPORT to read a comma-separated file, a tab-separated file, or other delimited file, the procedure does the following actions by default:
…
- creates a DATA step with an INPUT statement
- submits all of the code to the DATA step compiler, which, in turn, executes the code.
…
If you need to revise your code after the procedure runs, issue the RECALL command (or press F4) to the generated DATA step. At this point, you can add or remove options from the INFILE statement and customize the INFORMAT, FORMAT, and INPUT statements to your data.
So the steps will be
- Submit a
Proc IMPORT
that outputs zero rows.
The only thing wanted from this step is the source code generated by the procedure
- Open a new edit window (i.e. menu View/Enhanced Editor)
- Issue the
RECALL
command in the command bar (or menu Run/Recall Last Submit)
- Edit the recalled source code
- Remove the limiter where=(1=0))
- Change the INFORMAT
from best32.
to something like $32.
- Remove the corresponding FORMAT
statement
- Submit the edited code
Example:
Create sample data set with too big integers and IMPORT
it
filename myfile temp;
data _null_;
file myfile;
put "one;two;three";
put "1;2;3";
put "301185964728506014850593;301185964728506014850594;301185964728506014850595";
put "301185964728506014850593;301185964728506014850594;301185964728506014850595";
put "301185964728506014850593;301185964728506014850594;301185964728506014850595";
put "301185964728506014850593;301185964728506014850594;301185964728506014850595";
put "301185964728506014850593;301185964728506014850594;301185964728506014850595";
put "301185964728506014850593;301185964728506014850594;301185964728506014850595";
run;
proc import
file=myfile
dbms=dlm
replace
out=myimport(where=(1=0) /* output limiter */
;
delimiter=';';
run;
Recall the SAS source code, edit it and resubmit
/**********************************************************************
* PRODUCT: SAS
* VERSION: 9.4
* CREATOR: External File Interface
* DATE: 07NOV19
* DESC: Generated SAS Datastep Code
* TEMPLATE SOURCE: (None Specified.)
***********************************************************************/
data WORK.MYIMPORT
/*(where=(1=0)) */ /* <------ remove limiter */
;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile MYFILE delimiter = ';' MISSOVER DSD lrecl=32767 firstobs=2 ;
informat one $32. ; /* <-------- change informats */
informat two $32. ;
informat three $32. ;
/* format one best12. ;*/ /* <--------- remove format statements */
/* format two best12. ;*/
/* format three best12. ;*/
input
one
two
three
;
if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */
run;
Yields the data set
Obs one two three
1 1 2 3
2 301185964728506014850593 301185964728506014850594 301185964728506014850595
3 301185964728506014850593 301185964728506014850594 301185964728506014850595
4 301185964728506014850593 301185964728506014850594 301185964728506014850595
5 301185964728506014850593 301185964728506014850594 301185964728506014850595
6 301185964728506014850593 301185964728506014850594 301185964728506014850595
7 301185964728506014850593 301185964728506014850594 301185964728506014850595