SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Merging SAS Data Sets
Selecting Variables


Where to Specify DROP= and KEEP=

You can specify DROP= and KEEP= anywhere you name a SAS data set. When match-merging, you can specify these options in either the DATA statement or the MERGE statement, depending on whether or not you want to process values of the variables in that DATA step:

  • If you don't process certain variables and you don't want them to appear in the new data set, specify them in the DROP= option in the MERGE statement.
       merge clinic.demog(in=indemog 
                          rename=(date=BirthDate)) 
             clinic.visit(drop=weight in=invisit); 
    
  • If you do need to process a variable in the original data set (in a subsetting IF statement, for example), you must specify the variable in the DROP= option in the DATA statement. Otherwise, the statement using the variable for processing causes an error.
       data clinic.combined(drop=id); 
    

    Used in the DATA statement, the DROP= option simply drops the variables from the new data set. However, they are still read from the original data set and are available within the DATA step.

back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement