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.
Creating new variables and conditional processing - SAS Tutorial
From the course: SAS Programming for R Users, Part 1
Creating new variables and conditional processing
- [Instructor] In this section, I'll show you how to create and add new variables to the data table using a DATA step. In R, we typically use the dollar sign syntax to add a variable to our data frame. I'll how you how to do the same thing with a DATA step. And by the end of this section, I want to show you how to conditionally create a variable using syntax like if, else if, and else functions. To add a variable to a dataset, we're going to start with our DATA step, specify the name of the data table we're working with, and the same name in the set statement. Again, this overrides the existing data table with your changes. So here, I'm creating a new variable called wheelbase underscore plus underscore length, and I'm just adding together two variables in the cars dataset. And you can go ahead and add in as many variables as you want in a single DATA step. Moving on, let's go ahead and create variables conditionally now, and let's motivate this with an example. Suppose car…
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)