SAS - IF-THEN-DELETE Statement



An IF-THEN-DELETE statement consists of a boolean expression followed by SAS THEN DELETE statement.

Syntax

The basic syntax for creating an if statement in SAS is −

IF (condition ) THEN DELETE;

If the condition evaluates to be true, then the respective observation is processed.

Example

DATA EMPDAT;
INPUT   EMPID ENAME $ SALARY DEPT $ DOJ DATE9.;
LABEL ID = 'Employee ID';
FORMAT DOJ DATE9.;
DATALINES;
1 Rick 623.3 IT 02APR2001
2 Dan 515.2 OPS 11JUL2012
3 Mike 611.5 IT 21OCT2000
4 Ryan 729.1 HR 30JUL2012
5 Gary 843.2 FIN 06AUG2000
6 Tusar 578.6 IT 01MAR2009
7 Pranab 632.8 OPS 16AUG1998
8 Rasmi 722.5 FIN 13SEP2014
;
Data EMPDAT1;
Set EMPDAT;
IF SALARY > 700 THEN DELETE;
PROC PRINT DATA = EMPDAT1;
run; 

When the above code is executed, it produces the following result −

sas_if_then_delete_result.JPG
sas_decision_making.htm
Advertisements