Creating Variables and Statements
Creating Variables and Statements
Creating Variables and Statements
In SAS, you can create new variables using an assignment statement with this general form:
variable = expression;
You name the variable on the left-hand side of the equal sign and tell SAS what value you want this
variable to assume on the right-hand side. If this is a new variable, SAS will add it to your data set; if the
variable already exists, SAS replaces the old value with the new.
DATA test;
INPUT y;
Value = 1;
Value2 = '1';
Value3 = y + 1;
DATALINES;
40
32
38 ;
Run;
1 40 1 1 41
2 32 1 1 33
3 38 1 1 39
GOTO Statement
GOTO label ;
The GOTO statement causes a program to jump to a new statement in the program. When the
GOTO statement is executed, the program jumps immediately to the statement with the
given label and begin executing statements from that point.
STOP Statement:
STOP ;
The STOP statement stops the program, and no further matrix statements are executed.
ERROR Statement:
Syntax:
ERROR <message>;
Details:
The ERROR statement sets the automatic variable _ERROR_ to 1. Writing a message that you
specify to the SAS log is optional. When _ERROR_ = 1, SAS writes the data lines that correspond
to the current observation in the SAS log.
Using ERROR is equivalent to using these statements in combination:
OUTPUT writes observations to a SAS data set; PUT writes variable values or text
strings to an external file or the SAS log.