Site LogoIntroduction to SAS: Keep Statement

Download the SAS Tutorial in a single PDF file from the SAS Tutorial page. The online tutorial will be eliminated in August 2017.

Contents Index

Used in the datastep, the keep statement explicitly specifies which variables are to be retained in the data set. Example:

data score;
infile `c:\courses\mh160.dat';
input last $ first $ m1-m3 final;
keep last first grade;

The data set score will contain only the 3 variables last, first, and grade. If the keep statement were not used, the data set would contain 7 variables: last, first, m1, m2, m3, final, and grade.

It is preferable to use the keep= data set option.

© Copyright 2016 Jerry Alan Veeh. All rights reserved.