Previous Page | Next Page

Copying, Moving, and Deleting SAS Data Sets

Deleting All Files in a SAS Data Library

To delete all files in a SAS data library at one time, use the KILL option in the PROC DATASETS statement.

CAUTION:
The KILL option deletes all members of the library immediately after the statement is submitted.

You are not asked to verify the delete operation, so be sure that you intend to delete the files before submitting the program.  [cautionend]

For example, the following program deletes all data sets in the library WEATHER and stops the DATASETS procedure:

proc datasets library=weather kill;
run;
quit;

The following output shows the SAS log:

Deleting All Members of the Library WEATHER

250  proc datasets library=weather kill;
                              -----Directory-----

                   Libref:            WEATHER                
                   Engine:            V8                     
                   Physical Name:     external-file
                   File Name:         external-file
                   Inode Number:      1864996                
                   Access Permission: rwxr-xr-x              
                   Owner Name:        userid                 
                   File Size (bytes): 4096                   


                                        File
               #  Name       Memtype    Size  Last Modified
              ---------------------------------------------------
               1  BASETEMP   CATALOG   20480   16NOV2000:11:15:14
               2  HIGHTEMP   DATA      16384   16NOV2000:11:14:50
               3  HURRICANE  DATA      16384   16NOV2000:11:15:19
               4  LOWTEMP    DATA      16384   16NOV2000:11:14:53
               5  RAIN       DATA      16384   16NOV2000:11:15:00
               6  REPORT     CATALOG   20480   16NOV2000:11:15:30
               7  SNOW       DATA      16384   16NOV2000:11:15:06
               8  TEMPCHNG   DATA      16384   16NOV2000:11:15:36
               9  TORNADO    DATA      16384   16NOV2000:11:14:46
              10  USHIGH     DATA      16384   16NOV2000:11:15:40
              11  USLOW      DATA      16384   16NOV2000:11:15:46
NOTE: Deleting WEATHER.BASETEMP (memtype=CATALOG).
NOTE: Deleting WEATHER.HIGHTEMP (memtype=DATA).
NOTE: Deleting WEATHER.HURRICANE (memtype=DATA).
NOTE: Deleting WEATHER.LOWTEMP (memtype=DATA).
NOTE: Deleting WEATHER.RAIN (memtype=DATA).
NOTE: Deleting WEATHER.REPORT (memtype=CATALOG).
NOTE: Deleting WEATHER.SNOW (memtype=DATA).
NOTE: Deleting WEATHER.TEMPCHNG (memtype=DATA).
NOTE: Deleting WEATHER.TORNADO (memtype=DATA).
NOTE: Deleting WEATHER.USHIGH (memtype=DATA).
NOTE: Deleting WEATHER.USLOW (memtype=DATA).
251  run;
252  quit;

Note:   All data sets and catalogs are deleted from the SAS data library, but the libref is still assigned for the session. The name that is assigned to the library in your operating environment is not removed when you delete the files that are included in the library.  [cautionend]

Previous Page | Next Page | Top of Page