ARCHIVED: In SAS, how do I remove observations?

This content has been archived, and is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable.

To remove observations in SAS, you can use the IF statement in a DATA step. Suppose you want to exclude all observations whose scores are greater than 100. Consider the following example:

  DATA new;
     SET old;
     IF score <= 100;

The above DATA step reads the data set old, and then removes all observations that do not meet the condition specified in the IF statement. The result is stored in the data set new.

You can also use the IF statement in different ways; the following IF statements are equivalent to the one listed above:

  IF score <= 100 THEN OUTPUT;
  IF score > 100 THEN DELETE;

If you have questions about using statistical and mathematical software at Indiana University, contact the UITS Research Applications and Deep Learning team.

This is document affu in the Knowledge Base.
Last modified on 2018-01-18 10:18:46.