REMOVE Statement


Deletes an observation from a SAS data set

Valid: in a DATA step

Category: Action

Type: Executable

Restriction: Use only with a MODIFY statement.

Syntax

REMOVE < data-set- name (s) >;

Without Arguments

If you specify no argument, the REMOVE statement deletes the current observation from all data sets that are named in the DATA statement.

Arguments

data-set-name

  • specifies the data set in which the observation is deleted.

  • Restriction: The data set name must also appear in the DATA statement and in one or more MODIFY statements.

Details

The deletion of an observation can be physical or logical, depending on the engine that maintains the data set. Using REMOVE overrides the default replacement of observations. If a DATA step contains a REMOVE statement, you must explicitly program all output for the step.

Comparisons

  • Using an OUTPUT, REPLACE, or REMOVE statement overrides the default write action at the end of a DATA step. (OUTPUT is the default action; REPLACE becomes the default action when a MODIFY statement is used.) If you use any of these statements in a DATA step, you must explicitly program all output for new observations.

  • The OUTPUT, REPLACE, and REMOVE statements are independent of each other. More than one statement can apply to the same observation, as long as the sequence is logical.

  • If both an OUTPUT and a REPLACE or REMOVE statement execute on a given observation, perform the OUTPUT action last to keep the position of the observation pointer correct.

  • Because the REMOVE statement can perform a physical or a logical deletion, REMOVE is available with the MODIFY statement for all SAS data set engines. Both the DELETE and subsetting IF statements perform only physical deletions; therefore, they are not available with the MODIFY statement for certain engines.

Examples

This example removes one observation from a SAS data set.

 libname perm '  SAS-data-library  ';  data perm.accounts;     input AcctNumber Credit;     datalines;  1001 1500  1002 4900  1003 3000  ;  data perm.accounts;     modify perm.accounts;     if AcctNumber=1002 then remove;  run;  proc print data=perm.accounts;     title 'Edited Data Set';  run; 

Here are the results of the PROC PRINT statement:

 Edited Data Set             1        Acct  OBS  Number  Credit   1    1001    1500   3    1003    3000 

See Also

Statements:

  • DELETE Statement on page 1137

  • IF Statement, Subsetting on page 1212

  • MODIFY Statement on page 1307

  • OUTPUT Statement on page 1339

  • REPLACE Statement on page 1378




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net