• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Programming Expert

Solving All of Your Programming Headaches

  • HTML
  • JavaScript
  • jQuery
  • PHP
  • Python
  • SAS
  • Ruby
  • About
You are here: Home / SAS / SAS Delete Dataset – Use PROC Datasets to Delete SAS Files

SAS Delete Dataset – Use PROC Datasets to Delete SAS Files

January 17, 2022 Leave a Comment

To delete a dataset in SAS, the easiest way is to use PROC datasets and the DELETE statement:

proc datasets library=work;
   delete dataset1;
run;

When working with data in SAS, sometimes we want to delete datasets to clear up space in our working directory or on our data servers.

We can easily delete datasets in SAS with PROC Datasets.

The key to getting rid of a SAS file is using the DELETE statement.

Deleting a Dataset using PROC Datasets in SAS

To delete a SAS file using PROC Datasets, all we need to do is list the file after a DELETE statement.

Let’s say I have a SAS file called “dataset1” in a directory which I’ve assigned to “mylib”. I can delete “dataset1” with the following SAS code:

proc datasets library=mylib;
   delete dataset1;
run;

Deleting Multiple Datasets using PROC Datasets in SAS

To delete multiple SAS files using PROC Datasets, all we need to do is list the files after a DELETE statement.

Let’s say I have 2 SAS files called “dataset1” and “dataset2” in a directory which I’ve assigned to “mylib”. I can delete both SAS datasets with the following SAS code:

proc datasets library=mylib;
   delete dataset1 dataset2;
run;

Deleting All Datasets in a Directory using PROC Datasets in SAS

To delete all datasets in a directory, after the DELETE statement we don’t list any files.

proc datasets library=mylib;
   delete;
run;

Hopefully this article has been useful for you to understand how to use PROC datasets to delete datasets in your SAS code.

Other Articles You'll Also Like:

  • 1.  SAS year function – Get Year from Date Variable
  • 2.  SAS yymmdd10. Date Format
  • 3.  SAS Proper Case – Capitalize First Letter of Word with propcase Function
  • 4.  SAS where in – Subset Data by Multiple Values in Data Step
  • 5.  SAS data _null_ – Create a SAS Dataset with No Records and Variables
  • 6.  SAS Remove Formats from Dataset with PROC DATASETS
  • 7.  SAS call symput – Create Macro Variables in Data Step
  • 8.  Round Number to 2 Decimal Places in SAS
  • 9.  SAS trim – Remove All Trailing Blanks from String Variable in Data Step
  • 10.  SAS mean() Function – Find Average Across Columns in Data Step

About The Programming Expert

The Programming Expert is a compilation of a programmer’s findings in the world of software development, website creation, and automation of processes.

Programming allows us to create amazing applications which make our work more efficient, repeatable and accurate.

At the end of the day, we want to be able to just push a button and let the code do it’s magic.

You can read more about us on our about page.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About The Programming Expert

the programming expert main image

Welcome to The Programming Expert. We are a group of US-based programming professionals who have helped companies build, maintain, and improve everything from simple websites to large-scale projects.

We built The Programming Expert to help you solve your programming problems with useful coding methods and functions in various programming languages.

Search

Learn Coding from Experts on Udemy

Looking to boost your skills and learn how to become a programming expert?

Check out the links below to view Udemy courses for learning to program in the following languages:

Copyright © 2023 · The Programming Expert · About · Privacy Policy