From the course: SAS® 9.4 Cert Prep: Part 04 Preparing Data

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Processing multiple statements with IF-THEN/DO

Processing multiple statements with IF-THEN/DO - SAS Tutorial

From the course: SAS® 9.4 Cert Prep: Part 04 Preparing Data

Processing multiple statements with IF-THEN/DO

- [Instructor] If you can specify a compound condition to a evaluate, can you do the same after the keyword then to execute multiple statements? No, if you try and use and between two statements the program fails with a syntax error because you can only have one executable statement following then. Don't worry. SAS has another way to execute multiple statements for a given condition. We call this syntax, if then do. After condition, you type then do and a semicolon. After that statement you can list as many statements as you need to process. At the end, you close the block of statements with an end statement. This is repeated for each of the else if blocks. For the last statement, you use else do since you're not evaluating an expression in the last statement. Suppose we want to conditionally write output to two different tables. In the data statement we can list more than one output table. So in this example we…

Contents