BookmarkSubscribeRSS Feed
V_Andy
Fluorite | Level 6
Hello!

One of the variables in my source of data is number of 16 characters.
I want this variable to have a numeric format in my dataset.
When I import data into SAS, using EG import wizard, I choose numeric format, but only 12 characters appear with trimming 4 last numbers.

Can anybody explain how to import long numbers in SAS.
8 REPLIES 8
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello V. Andy,

I tried to import text file contating long number with EG 4.3 import wizard. It was successful but I have to change Source Informat, Output Format and Output Format to BEST20.

Sincerely,
SPR
TomKari
Onyx | Level 15
Be careful with numbers with large numbers of digits; 15 significant digits is the most that will be accurately retained on most processors today. 16 digit and larger numbers risk losing accuracy.

Tom
Patrick
Opal | Level 21
Hi

If you don't need these digits for calculations then better store it in a character variable. Else you're going to have precision problems.

HTH
Patrick
V_Andy
Fluorite | Level 6
Thanks to everybody for help!

I just wanted to increcase the database productivity and decrease space occupied by dataset. I thought I could do it keeping my field in numeric format rather than in character.
SASKiwi
PROC Star
I'm with TomKari and Patrick on this one. If you have ever dealt with bank data, account numbers and credit card numbers are typically up to 16 digits long and so are always stored as character to avoid precision issues.
Peter_C
Rhodochrosite | Level 12
I find all releases of SAS can support 16digit numbers in numeric variables. Unfortunately, the default behaviour of excel is to convert the 16th (on th eright) to zero!
Unsigned packed decimal (format/informat PK.) saves half the storage over strings.
have a look at the saslog after running this code, as tested on AIX
data;
input a : best20. ;
file "&sysuserid/test.hex.data" ;
put a pk8. ;
list;cards;
1234567812345678
-3456
0
88888888888888888
;
data ;
infile "&sysuserid/test.hex.data" ;
input @;
list ;
run;
TomKari
Onyx | Level 15
Yes, SOME 16 digit numbers will be represented correctly, but large numbers will fail. In windows, the following code

data work.digit_test;
a = 9234567812345670; put a 16.;
a = 9234567812345671; put a 16.;
a = 9234567812345672; put a 16.;
a = 9234567812345673; put a 16.;
a = 9234567812345674; put a 16.;
a = 9234567812345675; put a 16.;
a = 9234567812345676; put a 16.;
a = 9234567812345677; put a 16.;
a = 9234567812345678; put a 16.;
a = 9234567812345679; put a 16.;
run;

produces this log.

9234567812345670
9234567812345672
9234567812345672
9234567812345672
9234567812345674
9234567812345676
9234567812345676
9234567812345676
9234567812345678
9234567812345680

According to the SAS Unix notes, the code should fail in your environment as well. Give it a try, and post back what happens.

Tom
Peter_C
Rhodochrosite | Level 12
Tom is correct, of course.
On windows and Unix not all 16 digit numbers can be presented accurately. The rule is about size. (and notice that in Tom's examples, even numbers seem OK)

The SAS Companions for SAS on Windows and Unix, show that the highest integer up to which integers are presented reliably, is 9,007,199,254,740,992.
In "SAS 9.2 Companion for Windows, Second Edition", see http://support.sas.com/documentation/cdl/en/hostwin/63285/HTML/default/numvar.htm#maxint

On the zOS platform the limit is higher at 72,057,594,037,927,936
So, on zOS platform there shouild be no problem holding and using a 16 digit number.

peterC just to add that results from Toms data step are the same when run in unix (aix-64) Message was edited by: Peter.C

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 11502 views
  • 0 likes
  • 6 in conversation