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 - 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…
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)
Creating new variables and conditional processing5m 38s
-
(Locked)
Conditionally creating variables with a DO group2m 53s
-
(Locked)
Using SAS functions4m 12s
-
(Locked)
Using SAS functions on character data4m 37s
-
(Locked)
Demo: SAS function documentation2m 2s
-
(Locked)
Creating functions for the DATA step5m 20s
-
(Locked)
Subsetting data3m 38s
-
(Locked)
Concatenating data sets2m 18s
-
(Locked)
Match-merging data sets2m 41s
-
(Locked)