## Wednesday, February 11, 2009

### Length of Numeric variables GT 8 in SAS| StudySAS BLOG

Q&A: numeric variables length more than 8? We all know that the default length of the numeric variables in SAS is 8 and if suppose I want to store a number lets say (12345678910, which has a length 11 to numeric variable) to variable total, what should I do?

What if the numeric variable digits are more than 12 digits and i want to store them all without any E values?

ANS)

The default length of numeric variables in SAS is 8 and all the numbers that we see in the sas datasets are called as floating numbers(floating point binary) and not a regular sequence numbers form 1 to 10. When we are using SAS/Windows as our operating system and then the minimum length for any numeric variable should be 3(not 1 as we get confused all the time). So if a variable contas less than 3 digits means it is stored with less space.

The reason is, since a numeric variable will need a power and and the sign(+ or -), if SAS want to store a numberit defenitely needs a minimum of 3 bytes.

Depending upon the operating system we are using for SAS, the range for numeric variables can be 2 to 8 or 3 to 8.

Since the type of floating-point values is upto 16 decimal digits. we can store numbers upto 16(1234567891012234) total 16 digits for a numeric variable, but that can be possible if we use a format statement.

Ex:
data dsn;

a=1234567891012234;
format a best16.;run;

If we open the output, we can see all the 16 digits were stored for the variable a exactly in the dataset dsn.

If the the value of numeric variable is upto 12 disgits we don't require to specify any formats, if it is more than 12 digits we have to mention specify the format statement. without it we will see error in the system log.

Kiran R said...

CRM Segmentation and Clustering Using SAS Enterprise Miner (Sas Press Series) by Randall S. Collica (Paperback - Jun 4, 2007)

Do you have this book?
http://www.amazon.com/Segmentation-Clustering-Using-Enterprise-Miner/dp/1590475089/ref=sr_1_1?ie=UTF8&s=books&qid=1234502810&sr=1-1

Anonymous said...

sarath, can't we use 'Length' statement instead?

sarath said...

by default .... all numeric values can have a max...length 8...

length statement .. wont.. work... if the ..value is more than 8 digits...

Anonymous said...

what is the length of two numeric variables which are concatenated using || operator.

sarath said...

When you concatenate 2 numeric variables using concatenate operator ||(pipe) the resultant variable you get is a character variable.... Length of the new variable ... is \$24....

Anonymous said...

how did u get length as 24 can u explain it in detail?