Search for "SAS numeric precision".
You can store 256 numbers, 0 to 255. They have 1 to 3 digits.
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.
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.
@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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.