From the course: SAS Programming for R Users, Part 1

Unlock this course with a free trial

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

Conditionally creating variables with a DO group

Conditionally creating variables with a DO group - SAS Tutorial

From the course: SAS Programming for R Users, Part 1

Conditionally creating variables with a DO group

- [Instructor] In the previous examples when I was using my if, else if, and else statements, we only executed a single statement after the keyword then. Well, what if I want to create multiple variables, meaning I have to execute multiple statements. I need to go ahead and use a SAS DO group. And the SAS DO group is very common going forward. In this series, we'll see it when we do matrix simulation and we want to execute something conditionally. So, it's a great piece of syntax to keep in your back pocket. So, how do we use the DO group? Well, we begin the same way, if, specify our expression, then we use the keyword do followed by a semicolon. And then, we execute whatever statements we want to create as many variables as we want. And remember, always end your DO groups with the end statement. And the same goes for the else if and else statements as well. So, to practice using the DO group, let's motivate again with an example. So, now, suppose car manufacturers receive an economic…

Contents