SAS Language Concepts

SAS Data Sets, Tables, and Variables

A SAS data set is a file whose contents are represented in a format that is specific to SAS. In database management systems, a SAS data file is typically referred to as a two-dimensional table.
SAS uses the term “observation” to refer to rows in a table. Each observation is one row. SAS uses the term “variable” to refer to columns in a table. Each variable is a column in a table. The data values for each variable describe the characteristics (attributes) of that variable for all observations. Each SAS variable can have the following attributes:
  • name
  • data type (character or numeric)
  • length
  • format
  • informat
  • label

SAS Libraries

A SAS library is a collection of related SAS files and is similar in concept to a folder. In directory-based operating environments, a SAS library is a group of SAS files that are stored in the same directory and accessed by the same engine. Other files can be stored in the directory, but only the files with file extensions that are assigned by SAS are recognized as part of the SAS library.

SAS Formats

SAS formats control the way that SAS data is displayed. For example, for the variable COST, the format might be DOLLAR10.2. This format displays the value of COST with a leading dollar sign and a maximum length of 12 characters that includes two decimal positions. SAS Universal Viewer applies formats by default.

SAS Informats

An informat is an instruction that SAS uses to read data values into a variable. For example, the following value contains a dollar sign and commas: $1,000,000. To remove the dollar sign ($) and commas (,) before storing the numeric value 1000000 in a variable, you can read this value with the COMMA11. informat. Unless you explicitly define a variable first, SAS uses the informat to determine whether the variable is numeric or character. SAS also uses the informat to determine the length of character variables.

Variable Labels

A label is descriptive text that is associated with a SAS data set variable. Each variable or column in a SAS data set has a name that is used within the SAS code. Using a label to refer to a variable can make it easier to understand what a variable represents. SAS allows a label to be associated with each variable in a SAS data set.