0% found this document useful (0 votes)
41 views3 pages

Creating Variables and Statements

The document discusses creating and redefining variables in SAS. It provides an example where new variables are created and assigned values using assignment statements. The variables Value, Value2, and Value3 are created and assigned the values 1, '1', and the value of y plus 1 respectively in the test data set. This allows SAS to add new variables to a data set or replace the values of existing variables.

Uploaded by

hima
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views3 pages

Creating Variables and Statements

The document discusses creating and redefining variables in SAS. It provides an example where new variables are created and assigned values using assignment statements. The variables Value, Value2, and Value3 are created and assigned the values 1, '1', and the value of y plus 1 respectively in the test data set. This allows SAS to add new variables to a data set or replace the values of existing variables.

Uploaded by

hima
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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.

You might also like