Assigning Values Conditionally Using SELECT Groups

Overview

Earlier in this chapter, you learned to assign values conditionally using IF-THEN/ELSE statements. You can also use SELECT groups in DATA steps to perform conditional processing. A SELECT group contains these statements:
This statement...
Performs this action...
SELECT
begins a SELECT group.
WHEN
identifies SAS statements that are executed when a particular condition is true.
OTHERWISE (optional)
specifies a statement to be executed if no WHEN condition is met.
END
ends a SELECT group.
You can decide whether to use IF-THEN/ELSE statements or SELECT groups based on personal preference.
General form, SELECT group:
SELECT <(select-expression) ...

Get SAS Certification Prep Guide: Base Programming for SAS 9, Third 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.