Join Jordan Bakerman for an in-depth discussion in this video Creating new variables and conditional processing, part of SAS Programming for R Users, Part 1.
- [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 manufacturers receive an economic incentive…
Note: You can visit the SAS site to obtain a copy of the software, and use the company's online data sets to do the course exercises.
- SAS University Edition
- Working in SAS Studio
- Using tasks and snippets in SAS Studio
- Determining power using simulation
- SAS procedure syntax
- Creating datasets manually in the DATA step
- Importing raw data files
- Creating new variables and conditional processing
- Match-merging data sets
Skill Level Beginner
Descriptive Healthcare Analytics in Rwith Monika Wahi4h 15m Advanced
1. Introduction and Working in SAS
2. Importing and Reporting Data
3. Creating New Variables, Functions, and Data Tables
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.