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 - 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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Demo: Conditional processing with IF-THEN3m 35s
-
(Locked)
Conditional processing with IF-THEN/ELSE1m 40s
-
(Locked)
Creating character columns with the LENGTH statement1m 10s
-
(Locked)
Processing multiple statements with IF-THEN/DO1m 39s
-
Demo: Processing multiple statements with IF-THEN/DO2m 54s
-
(Locked)