Figure 2.1 Submitted Programs Are Sent to the Input Stack
Once a program reaches the input stack, SAS transforms the stream of characters into
individual tokens. These tokens are transferred to different parts of SAS for processing,
such as the DATA step compiler and the macro processor. Knowing how SAS recognizes
tokens and how they are transferred to different parts of SAS will help you understand
how the various parts of SAS and the macro processor work together. Also, how to
control the timing of macro execution in your programs. The following sections show
you how a simple program is tokenized and processed.
How SAS Processes Statements without Macro
Activity
The process that SAS uses to extract words and symbols from the input stack is called
tokenization. Tokenization is performed by a component of SAS called the word
scanner, as shown in Figure 2.2 on page 17. The word scanner starts at the first
character in the input stack and examines each character in turn. In doing so, the word
scanner assembles the characters into tokens. There are four general types of tokens:
Literal
a string of characters enclosed in quotation marks.
16 Chapter 2 SAS Programs and Macro Processing
Number
digits, date values, time values, and hexadecimal numbers.
Name
a string of characters beginning with an underscore or letter.
Special
any character or group of characters that have special meaning to SAS. Examples of
special characters include: * / + - ** ; $ ( ) . & % =
Figure 2.2 The Sample Program before Tokenization
The first SAS statement in the input stack in the preceding figure contains eight tokens
(four names and four special characters).
data sales(drop=lastyr);
When the word scanner finds a blank or the beginning of a new token, it removes a
token from the input stack and transfers it to the bottom of the queue.
In this example, when the word scanner pulls the first token from the input stack, it
recognizes the token as the beginning of a DATA step. The word scanner triggers the
DATA step compiler, which begins to request more tokens. The compiler pulls tokens
from the top of the queue, as shown in the following figure.
How SAS Processes Statements without Macro Activity 17
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset