Subsetting

keep/drop

keep and drop work in the same way: they keep or drop variables or observations.

keep/drop var subsets data by variables.
. sysuse auto
. keep price

keep/drop if exp subsets observations by conditions.
. drop if price < 5000

keep/drop in range subsets observations within certain rows.
. keep in 10/20

Author: Yun Dai, 2018