Use of Drop= or Keep= data set options
The other way of subsetting variables is to keep or drop variables as the data are being read.
For example, create a data set with only Subj, Height, and Weight.
Data HtWt; Set library.Survey12 (KEEP= Subj Height Weight); Proc Print; ID Subj; Title 'Like Example 1.4 in C&P Chapter 3';
Again the Proc shows 5 observations and 3 variables
Like Example 1.4 in C&P Chapter 3 SUBJ HEIGHT WEIGHT 1 68 155 7 72 205 9 66 120 5 102 63 8 250 70
You can guess that there is a DROP= option and you can guess what it does.
Notice that the data set name options appear after the dataset name, library.Survey12, in a set of parentheses. The parentheses are required. There are other data set name options, all of which appear in the single set of parentheses after the data set name.
Efficiency note: since the DROP= and KEEP= options control which variables come into the data step, they are more efficient than their equivalent DROP statement or KEEP statement. However, the dropped variables are not available for use in the data step.