Previous Page | Next Page

The DATASETS Procedure

DELETE Statement


Deletes SAS files from a SAS library.
Featured in: Manipulating SAS Files

DELETE SAS-file-1 <...SAS-file-n>
</ <ALTER=alter-password>
<GENNUM=ALL|HIST|REVERT|integer>
<MEMTYPE=mtype>>;

Required Arguments

SAS-file-1 <...SAS-file-n>

specifies one or more SAS files that you want to delete. You can also use a numbered range list or colon list. For more information, see Data Set Lists.


Options

ALTER=alter-password

provides the alter password for any alter-protected SAS files that you want to delete. You can use the option either in parentheses after the name of each SAS file or after a forward slash.

See also: Using Passwords with the DATASETS Procedure
GENNUM=ALL|HIST|REVERT|integer

restricts processing for generation data sets. You can use the option either in parentheses after the name of each SAS file or after a forward slash. The following is a list of valid values:

ALL

refers to the base version and all historical versions in a generation group.

HIST

refers to all historical versions, but excludes the base version in a generation group.

REVERT|0

deletes the base version and changes the most current historical version, if it exists, to the base version.

integer

is a number that references a specific version from a generation group. Specifying a positive number is an absolute reference to a specific generation number that is appended to a data set's name; that is, gennum=2 specifies MYDATA#002. Specifying a negative number is a relative reference to a historical version in relation to the base version, from the youngest to the oldest; that is, gennum=-1 refers to the youngest historical version.

See also:

Restricting Processing for Generation Data Sets

"Understanding Generation Data Sets" in SAS Language Reference: Concepts

MEMTYPE=mtype

restricts processing to one member type. You can use the option either in parentheses after the name of each SAS file or after a forward slash.

Aliases: MT=, MTYPE=
Default: DATA
See also: Restricting Member Types for Processing
Featured in: Manipulating SAS Files

Details


Working with Generation Groups

When you are working with generation groups, you can use the DELETE statement to delete the following versions:


Deleting the Base Version and All Historical Versions

The following statements delete the base version and all historical versions where the data set name is A:

proc datasets;
   delete A(gennum=all);

proc datasets;
   delete A / gennum=all;

proc datasets gennum=all;
   delete A;

The following statements delete the base version and all historical versions where the data set name begins with the letter A:

proc datasets;
   delete A:(gennum=all);

proc datasets;
   delete A: / gennum=all;

proc datasets gennum=all;
   delete A:;


Deleting the Base Version and Renaming the Youngest Historical Version to the Base Version

The following statements delete the base version and rename the youngest historical version to the base version, where the data set name is A:

proc datasets;
   delete A(gennum=revert);

proc datasets;
   delete A / gennum=revert;

proc datasets gennum=revert;
   delete A;

The following statements delete the base version and rename the youngest historical version to the base version, where the data set name begins with the letter A:

proc datasets;
   delete A:(gennum=revert);

proc datasets;
   delete A: / gennum=revert;

proc datasets gennum=revert;
   delete A:;


Deleting a Version with an Absolute Number

The following statements use an absolute number to delete the first historical version:

proc datasets;
   delete A(gennum=1);

proc datasets;
   delete A / gennum=1;

proc datasets gennum=1;
   delete A;

The following statements delete a specific historical version, where the data set name begins with the letter A:

proc datasets;
   delete A:(gennum=1);

proc datasets;
   delete A: / gennum=1;

proc datasets gennum=1;
   delete A:;


Deleting a Version with a Relative Number

The following statements use a relative number to delete the youngest historical version, where the data set name is A:

proc datasets;
   delete A(gennum=-1);

proc datasets;
   delete A / gennum=-1;

proc datasets gennum=-1;
   delete A;

The following statements use a relative number to delete the youngest historical version, where the data set name begins with the letter A:

proc datasets;
   delete A:(gennum=-1);

proc datasets;
   delete A: / gennum=-1;

proc datasets gennum=-1;
   delete A:;


Deleting All Historical Versions and Leaving the Base Version

The following statements delete all historical versions and leave the base version, where the data set name is A:

proc datasets;
   delete A(gennum=hist);

proc datasets;
   delete A / gennum=hist;

proc datasets gennum=hist;
   delete A;

The following statements delete all historical versions and leave the base version, where the data set name begins with the letter A:

proc datasets;
   delete A:(gennum=hist);

proc datasets;
   delete A: / gennum=hist;

proc datasets gennum=hist;
   delete A:;

Previous Page | Next Page | Top of Page