From the course: SAS Programming for R Users, Part 1
Unlock this course with a free trial
Join today to access over 22,400 courses taught by industry experts.
Subsetting data - SAS Tutorial
From the course: SAS Programming for R Users, Part 1
Subsetting data
- [Narrator] In this section, I want to show you how to use a data step to subset columns, or maybe subset rows, and finally subset observations conditionally to a new sas data set. Previously I showed you how to print the unique levels of specific variables, in this section I'll actually show you how to create a data set of those unique levels as well. And then you can go ahead and concatenate them together to create a data set which is basically like a list in this case, coming from R. I also want to show you how to subset conditionally, for example maybe I want to pull out all the observations in the cars data set where the origin is equal to Asia, and, also perhaps Europe, and then I can row bind those together to create a new sas data set. Thus far, I've been saying to specify the data set in the data statement and the set statement as the same. Again, that would overwrite the existing data table with the changes. So, to subset a new data set, I'll specify the data set I want to…
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
-
-
-
-
-
Creating new variables and conditional processing5m 38s
-
Conditionally creating variables with a DO group2m 53s
-
Using SAS functions4m 12s
-
Using SAS functions on character data4m 37s
-
Demo: SAS function documentation2m 2s
-
Creating functions for the DATA step5m 20s
-
Subsetting data3m 38s
-
Concatenating data sets2m 18s
-
Match-merging data sets2m 41s
-