From the course: SAS Essential Training: 1 Descriptive Analysis for Healthcare Research

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

KEEP and DROP commands

KEEP and DROP commands - SAS Tutorial

From the course: SAS Essential Training: 1 Descriptive Analysis for Healthcare Research

Start my 1-month free trial

KEEP and DROP commands

- [Instructor] Okay remember our modular code? Now, we are already on to next code, 105_Keep Variables. This code is in your exercise files for this movie. As you probably guessed, I'm going to show you how to keep just the variables you want from this big data set with 279 variables in it. Let's start with the first line of our data step. What we are trying to do is to make a new data set, called BRFSS_b that has only the variables we want to keep from BRFSS_a in it. So our first line says data r.BRFSS_b. And our set statement, specifies the data we are reading in which is of course r.BRFF_a. But wait, there's more. There's this keep option. You will see that there's an open parentheses right after the set statement and before the semi-colon you always need at the end of a code line in SAS. It's after this parentheses that the keep statement is placed, And then an =. And then a laundry list of the variables I said I wanted to keep. But of course you don't have to format your code…

Contents