BookmarkSubscribeRSS Feed
balu_g
Fluorite | Level 6
 
 
Hi, I have a question? numeric and character data has default length is 8 bytes. In the character data "one byte for one character." Then how many digits can store in one byte?
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5 REPLIES 5
mkeintz
PROC Star

Search for "SAS numeric precision".

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
WarrenKuhfeld
Ammonite | Level 13

You can store 256 numbers, 0 to 255. They have 1 to 3 digits.

SASKiwi
PROC Star

I assume this is a theoretical question as you can't define a 1 byte numeric variable in SAS. For Windows / Unix the minimum is 3 bytes.

Kurt_Bremser
Super User

It depends on how you store your numbers.

If stored as character in human-readable form, you obviously have one digit per byte.

If stored as character, but with the IBM packed decimal format, you have 2 digits per byte.

If you do some trickery and work with pure integers in character strings, each byte can hold 256 numbers, so the number of digits is that of the number 256 ** (number of bytes) - 1.

As mentioned, numeric has a minimum length of 3, and for that, search for "SAS numeric precision" to know how the storage lengths influence the maximum precision and the largest integer that can be stored exactly.

ballardw
Super User

@balu_g wrote:
 
 
Hi, I have a question? numeric and character data has default length is 8 bytes. In the character data "one byte for one character." Then how many digits can store in one byte?
 

For actual use in SAS datasets, that is a question of little concern as the smallest numeric variable in bytes is 2 or 3 (and mostly 3 IIRC)

length

specifies a numeric constant that is the number of bytes used for storing variable values.

Range For numeric variables, 2 to 8 or 3 to 8, depending on your operating environment. For character variables, 1 to 32767 under all operating environments.

 

 

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 1698 views
  • 1 like
  • 6 in conversation