SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Reading and Concatenating SAS Data Sets
Selecting Variables


When you create a new data set, you can use options to drop or keep variables that are stored in the original data set. You name the variables that you want to drop or keep using the DROP= and KEEP= data set options.

You can use the KEEP= option instead of the DROP= option if more variables are dropped than kept. You specify data set options in parentheses after a SAS data set name.


General form, DROP= and KEEP= data set options:
(DROP=variable-1 < . . . variable-n>)
(KEEP=
variable-1 < . . . variable-n>)

where

  • the DROP= or KEEP= option, in parentheses, follows the name of the data set containing the variables to be dropped or kept
  • variable is the name of one or more variables, separated by blanks.


Because you are only interested in treadmill time and tolerance levels, for example, you may want to drop the variables ID, Name, RestHR, MaxHR, and RecHR and keep the variables TimeMin, TimeSec, and Tolerance when you create the TestTime data set.

     data work.testtime(keep=timemin timesec tolerance);
        set clinic.stress2(drop=id name
resthr maxhr rechr)
;
if placebo='YES'; run;

SAS Data Set Stress2 (Partial Listing)
ID Name RestHR MaxHR RecHR TimeMin TimeSec Tolerance
2458 Murray, W 72 185 182 12 38 D
2462 Almers, C 68 171 133 10 5 I
2501 Bonaventure, T 78 177 139 11 13 I
2523 Johnson, R 69 162 114 9 42 S



back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.
Terms of Use & Legal Information | Privacy Statement