PROC DELETE: it's not dead yet

15

The DELETE procedure is probably the most well-known and most-used SAS procedure that isn't actually documented or officially supported. That is, that was the case before the release of SAS 9.4, when PROC DELETE returns with more features than ever -- including a production-quality status.

LEARN MORE | How to delete SAS data sets

In his SAS Global Forum paper, Optimize Your Delete, SAS developer Brad Richardson describes PROC DELETE's new lease on life, and how it can actually do a better/faster job of cleaning up your SAS data libraries.

Read the paper for the details, but conceptually PROC DELETE is the "Dirty Harry" of SAS utility procs. It shoots first and asks questions later, which makes it super fast. From Brad's paper:

... unlike PROC DATASETS, PROC DELETE does not check to see if the selected data set actually exists before trying to remove the file. Only after the attempt to erase the file will PROC DELETE know whether the data set actually existed, because there is no overhead to get the member names from disk...

Many people will never know about PROC DELETE's near-death experience. Even though it's been lurking within Base SAS for decades, PROC DELETE could not be allowed to continue as-is. SAS software and infrastructure has evolved considerably to take advantage of new hardware and operating system capabilities. Even established SAS procedures and functions must be refreshed continuously to keeping them humming along. If a feature in the software becomes disused (especially something that is undocumented/unsupported), developers have to decide whether to invest the time to refresh it and test it, or "put it down" to prevent unstable behavior.

Fortunately for legacy SAS programs everywhere, PROC DELETE will live to see another day -- and another generation of SAS programmers.

Share

About Author

Chris Hemedinger

Director, SAS User Engagement

+Chris Hemedinger is the Director of SAS User Engagement, which includes our SAS Communities and SAS User Groups. Since 1993, Chris has worked for SAS as an author, a software developer, an R&D manager and a consultant. Inexplicably, Chris is still coasting on the limited fame he earned as an author of SAS For Dummies

15 Comments

  1. Grant Johnson on

    Is there a way to test if a data set can be deleted before actually deleting it? Or, a way to gracefully handle data sets that do not delete successfully?

    • Brad Richardson on

      Hi Grant,

      No, there is not a way to test if a dataset can be deleted before actually deleting the file. One of the reasons that we cannot provide a check is because of time dependencies. For example, at the time of a delete check the dataset may be able to be deleted, but if another user opens that same dataset before you can delete the file the deletion will fail.

      PROC DELETE will return an error message if the dataset cannot be deleted.

    • Grant...You could try the FILEEXIST or FEXIST functions to test for the file before trying to delete it. Rick Langston showed this to me years ago and it worked great to eliminate errors/warnings caused by trying to delete a file that does not exist.

  2. Rick Wicklin

    PROC DELETE: I'm not dead!
    CUSTOMER: Here -- he says he's not dead!
    SAS DEVELOPER: Yes, he is.
    PROC DELETE: I'm not!
    CUSTOMER: He isn't.
    SAS DEVELOPER: Well, he will be soon, he's very ill and not documented.
    PROC DELETE: I'm getting better!
    SAS DEVELOPER: No, you're not -- you'll be stone dead in a moment.
    CUSTOMER: Oh, I can't use him like that -- it's against regulations.
    PROC DELETE: I don't want to be depricated!
    SAS DEVELOPER: Oh, don't be such a baby.
    CUSTOMER: I can't use him...
    PROC DELETE: I feel fine!
    CUSTOMER: Sorry. I can't use it if it's not documented.
    SAS DEVELOPER: Well, when is your next upgrade?
    CUSTOMER: SAS 9.4.
    PROC DELETE: I think I'll go for a run.
    SAS DEVELOPER: You're not fooling anyone y'know. Well, I guess I could fix him up and document him.
    PROC DELETE: I feel happy... I feel happy.
    CUSTOMER: Ah, thanks very much.

  3. Hello Sir,

    Are there any work-arounds for the SAS 9.4 and Windows XP incompatibility? What specifically makes them not place nice? I am a die-hard XP and SAS user and don't want to give up either one. Please help!

    Regards,

    Derek Reed

    • Chris Hemedinger
      Chris Hemedinger on

      As new versions of SAS are developed and released, the platform support matrix must be continuously evaluated. Windows XP, while still in wide use in some places, has limited support from Microsoft. So for SAS 9.4 (which supports 64-bit Windows versions only) it's no longer a supported OS, while new versions (such as Windows Server 2012 and Windows 8) are supported. You will be able to use Windows XP with SAS 9.3 for a long time yet, but when you are ready for SAS 9.4 you'll have to update Windows as well.

  4. Pingback: What's new in the SAS programming language?

  5. Jack Hamilton on

    An option that means "Don't set a non-zero return code even if the data set doesn't exist" would be very useful. Set a non-zero return code only if the data set existed but could not be deleted.

  6. Removing PROC DELETE is about as absurd as was the idea of removing SAS 79 style macro statement support back in the early days of SAS Version 5 time-period, as I recall....

    • Chris Hemedinger
      Chris Hemedinger on

      Scott, that's the beauty of the SAS language: it grows with every release, but it's difficult to imagine deprecating any parts of it, even if better SAS methods come along. There's always somebody using each PROC or function for something, and often in ways we didn't expect!

  7. I saw Brad's presentation at MWSUG and loved it! I've been a PROC DELETE user since 1986, supported or not...LOL!

  8. Anders Kraftling on

    I use PROC DELETE all over the place. Especially to ”clean up” Excel-sheets before filling with SAS-data. Like:
    %if %sysfunc (EXIST(_xl.table)) %then %do;
    proc delete data=_xl.table; run;
    %end;
    PROC DATASETS supports wildcards to really clean up libnames. That’s even better.

Back to Top