Creating Variables

Assignment Statements

Use an assignment statement in any DATA step in order to modify existing values or create new variables.
Syntax, assignment statement:
variable=expression;
  • variable names a new or existing variable
  • expression is any valid SAS expression
Tip:The assignment statement is one of the few SAS statements that do not begin with a keyword.
For example, here is an assignment statement that assigns the character value Toby Witherspoon to the variable Name:
Name='Toby Witherspoon';

SAS Expressions

You use SAS expressions in assignment statements and many other SAS programming statements to do the following:
  • transform variables
  • create new variables
  • conditionally process ...

Get SAS Certification Prep Guide, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.