Selecting Variables

Overview

As with reading raw data or reading SAS data sets, you can specify the variables you want to drop or keep by using the DROP= and KEEP= data set options.
For example, the DATA step below reads all variables from Clinic.Demog and all variables except Weight from Clinic.Visit. It then excludes the variable ID from Clinic.Merged after the merge processing is complete.
data clinic.merged (drop=id); 
   merge clinic.demog(in=indemog 
                     rename=(date=BirthDate)) 
         clinic.visit(drop=weight in=invisit 
                     rename=(date=VisitDate)); 
   by id; 
   if indemog and invisit; 
run; 
proc print data=clinic.merged; 
run;
Selecting Variables
Selecting Variables

Where ...

Get SAS Certification Prep Guide: Base Programming for SAS 9, Third 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.