What are SAS Variables?
In addition to general information about the dataset, the descriptor portion contains information about the attributes of each variable in the data set. The attribute information includes the variables: Name, Type, Length, format, informat and label.
Name:
It identifies a variable that conforms to SAS naming rules. SAS naming Rule same as SAS data set.
- 1-32 characters long
- Must begin with letter or underscore
- Can continue with any combination of numbers, letters or underscore
Type:
It identify variable as numeric or character. Character variables can contain any values such as letters; number and special characters can be of 1 to 32,767 characters long. Numeric variable can contain only numeric values.
Length:
It refers number of bytes used to store each of the variables value in a SAS data set. LENGTH statement can be used to set the length of both numeric and character variable.
For numeric variable, default length is 8. If you modify using LENGTH statement it affect the length of numeric values only in output dataset; during processing all numeric length is 8.
Looking for Top Jobs in Data Science ? This blog post gives you all the information you need!
Format:
A Format is an instruction that SAS uses to write data values. Format is used to control the written appearance of data values, or in some cases, to group data values together for analysis.
SAS software offers a variety of character, numeric, and date and time formats. Format scan be created and stored using FORMAT statement.
Can permanently assign a format to a variable in a SAS data set, or can temporarily specify a format in a PROC step to determine the way the data values appear in the output
Default format is BEST12. For numeric value
$w. for a character variable
This blog will help you get a better understanding of SAS !
Check out the top SAS Interview Questions and Answers to learn what is expected from SAS professionals!
Informat:
Used to read data values in certain formats into standard SAS values. It determines how data values are read into a SAS data set. Informats are used to read numeric values that contain letters or other special characters
Default informat is w.d for numeric value
$w. for a character variable
Label:
A variable can have a label consisting of descriptive text up to 256 characters long
By default, many reports identify variables by their names, to display more descriptive information about the variable assign a label to that variable.
To learn about file concepts, go through our blog on File concepts in SAS.