Language Reference


PURGE Statement

  • PURGE ;

The PURGE data processing statement is used to remove observations marked for deletion and to renumber the remaining observations. This closes the gaps created by deleted records. Execution of this statement can be time-consuming because it involves rewriting the entire data set.

Caution: Any indexes associated with the data set are lost after a purge.

When you quit PROC IML, observations marked for deletion are not automatically purged.

The following example creates a data set named A. The EDIT statement opens the data set for editing. The DELETE statement marks several observations for deletion. As shown in FigureĀ 24.278, the observations are not removed and renumbered until the PURGE statement executes.

data a;
do i=1 to 10;
   output;
end;
run;

proc iml;
edit a;
pts = 3:8;
delete point pts;
list all;

purge;
list all;

Figure 24.278: Deleting and Purging Observations

   OBS         i                                                                
------ ---------                                                                
     1    1.0000                                                                
     2    2.0000                                                                
     9    9.0000                                                                
    10   10.0000                                                                
                                                                                

   OBS         i                                                                
------ ---------                                                                
     1    1.0000                                                                
     2    2.0000                                                                
     3    9.0000                                                                
     4   10.0000