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.
Using SAS functions - SAS Tutorial
From the course: SAS Programming for R Users, Part 1
Using SAS functions
- [Instructor] In this section, I want to show you to use some built-in SAS functions to assist in creating new variables, functions like sum, absolute, exponentiate, round, and so forth, and we'll use all these in a data step to create our new variables. And by the end of this section, I want to show you how to create your own user-defined function to be used inside of a data step. So here I have a function called mydivision in R with two arguments, numerator and denominator. I want to be able to return a value of zero if the denominator is zero. Otherwise, I just want to return the value numerator divided by denominator. So to create a new variable using built-in SAS function, we'll do it the exact same way in R. Here we'll use it in our data step. We have our data statement, our set statement, and here I'm creating a variable called log_price which I'm just setting equal to the log of msrp, meaning I'm just taking the log of every element in that variable. Now, most of these…
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)