18
When you write SAS programs, it's important to understand the attributes of the variables that
you use. For example, you might need to combine SAS data sets that contain same-named
variables. In this case, the variables must be the same type (character or numeric).
The following is a partial listing of the attribute information in the descriptor portion of the SAS
data set Clinic.Insure. Let's look at the name, type, and length variable attributes. You'll learn
about the format, informat, and label attributes later in this chapter.
Variable Type Length Format Informat Label
Policy Num 8 Policy Number
Total Num 8 DOLLAR8.2 COMMA10. Total Balance
Name Char 20 Patient Name
Name
Each variable has a name that conforms to SAS naming conventions. Variable names follow
exactly the same rules as SAS data set names. Like data set names, variable names
can be 1 to 32 characters long
must begin with a letter (A–Z, either uppercase or lowercase) or an underscore (_)
can continue with any combination of numbers, letters, or underscores.
Type
A variable's type is either character or numeric.
Character variables, such as Name (shown below), can contain any values.
Numeric variables, such as Policy and Total (shown below), can contain only
numeric values (the digits 0 through 9, +, -, ., and E for scientific notation).
A variable's type determines how missing values for a variable are displayed. In the following
data set, Name and Sex are character variables, and Age and Weight are numeric variables.
For character variables such as Name, a blank represents a missing value.
For numeric variables such as Age, a period represents a missing value.
Name Sex Age Weight