Chapter Contents

Previous

Next

Words in the SAS Language


Definition

A word or token in the SAS language is a collection of characters that communicates a meaning to SAS and is not divisible into smaller units capable of independent use. It can contain a maximum of 32,767 characters.

A word or token ends when SAS encounters one of the following:

Each word or token in the SAS language belongs to one of four categories:


Types of Words or Tokens

There are four basic types of words or tokens:

name
is a series of characters that begin with a letter or an underscore. Later characters can include letters, underscores, and numeric digits. A name token can contain up to 32,767 characters. In most contexts, however, SAS names are limited to a shorter maximum length, such as 32 or 8 characters. See Maximum Length of User-Supplied SAS Names. Examples of name tokens include:

literal
consists of 1 to 32,767 characters enclosed in single or double quotation marks. Examples of literals include

Note:   The surrounding quotation marks identify the token as a literal, but SAS does not store these marks as part of the literal token.  [cautionend]

number
in general is composed entirely of numeric digits, with an optional decimal point and a leading plus or minus sign. SAS also recognizes numeric values in the folllowing forms as number tokens: scientific (E-) notation, hexadecimal notation, missing value symbols, and date and time literals. Examples of number tokens include

special character
is usually any single keyboard character other than letters, numbers, the underscore, and the blank. In general, each special character is a single token, although some two-character operators, such as ** and <=, form single tokens. The blank can end a name or a number token, but it is not a token. Examples of special-character tokens include


Placement and Spacing of Words in SAS Statements

Spacing Requirements

  1. You can begin SAS statements in any column of a line and write several statements on the same line.

  2. You can begin a statement on one line and continue it on another line, but you cannot split a word between two lines.

  3. A blank is not treated as a character in a SAS statement unless it is enclosed in quotation marks as a literal or part of a literal. Therefore, you can put multiple blanks any place in a SAS statement where you can put a single blank, with no effect on the syntax.

  4. The rules for recognizing the boundaries of words or tokens determine the use of spacing between them in SAS programs. If SAS can determine the beginning of each token due to cues such as operators, you do not need to include blanks. If SAS cannot determine the beginning of each token, you must use blanks. See Examples.

Although SAS does not have rigid spacing requirements, SAS programs are easier to read and maintain if you consistently indent statements. The examples in this book illustrate useful spacing conventions.

Examples


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.