Selecting Variables

Where to Specify DROP= and KEEP= Data Set Options

When match-merging, specify these options in either the DATA statement or the MERGE statement, depending on whether you want to reference the variables in that DATA step:
  • To reference a variable in the original data set (in a subsetting IF statement, for example) specify the variable in the DROP= option in the DATA statement. Otherwise, you might get unexpected results and your variable would be uninitialized.
    data clinic.merged (drop=id);
  • To not reference certain variables and exclude them from 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 rename=(date=VisitDate)); ...

Get SAS Certification Prep Guide, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.