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.
Subscribe to:
Post Comments (Atom)
Learn how to view SAS dataset labels without opening the dataset directly in a SAS session. Easy methods and examples included!
Quick Tip: See SAS Dataset Labels Without Opening the Data Quick Tip: See SAS Dataset Labels With...
-
1) What do you know about CDISC and its standards? CDISC stands for Clinical Data Interchange Standards Consortium and it is developed ke...
-
Comparing Two Approaches to Removing Formats and Informats in SAS Comparing Two Approaches to Removing Formats...
-
USE OF THE “STUDY DAY” VARIABLES The permissible Study Day variables (--DY, --STDY, and --ENDY) describe the relative day of the observ...
CRM Segmentation and Clustering Using SAS Enterprise Miner (Sas Press Series) by Randall S. Collica (Paperback - Jun 4, 2007)
ReplyDeleteDo 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
sarath, can't we use 'Length' statement instead?
ReplyDeleteby default .... all numeric values can have a max...length 8...
ReplyDeletelength statement .. wont.. work... if the ..value is more than 8 digits...
what is the length of two numeric variables which are concatenated using || operator.
ReplyDeleteWhen 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....
ReplyDeletehow did u get length as 24 can u explain it in detail?
ReplyDelete