Sunteți pe pagina 1din 3

CREATING NEW VARIABLES OR REDEFINING VARIABLES:

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.

For example, consider the following statements

DATA test;
INPUT y;
Value = 1;
Value2 = '1';
Value3 = y + 1;

DATALINES;

40
32
38 ;

Run;

Obs y Value Value2 Value3

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:

an assignment statement setting _ERROR_ to 1


a FILE LOG statement
a PUT statement (if you specify a message)
a PUT; statement (if you do not specify a message)
another FILE statement resetting FILE to any previously specified setting
Output and Put statement:

OUTPUT writes observations to a SAS data set; PUT writes variable values or text
strings to an external file or the SAS log.

S-ar putea să vă placă și