PROC DELETE: it's not dead yet

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.

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.

tags: PROC DELETE, SAS 9.4

13 Comments

  1. Grant Johnson
    Posted July 8, 2013 at 1:53 pm | Permalink

    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
      Posted July 8, 2013 at 5:11 pm | Permalink

      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.

    • Rex Pruitt
      Posted November 26, 2014 at 6:08 am | Permalink

      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. Posted July 9, 2013 at 5:56 am | Permalink

    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.

    • Michelle B.
      Posted August 13, 2013 at 5:35 pm | Permalink

      FTW!

  3. Posted July 12, 2013 at 9:57 pm | Permalink

    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
      Posted July 22, 2013 at 8:44 am | Permalink

      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. Jack Hamilton
    Posted August 23, 2013 at 6:52 pm | Permalink

    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.

  5. Ronald J. Fehd
    Posted January 22, 2014 at 7:47 am | Permalink

    Ah, so! bringing back a happy user's often-used procedure!

    Here is some minimal documentation about why: it's faster!

    http://www.sascommunity.org/wiki/PROC_Delete

    Ron Fehd who knows deprecation is not Always a Good Thing

  6. Scott Barry
    Posted November 25, 2014 at 6:17 pm | Permalink

    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
      Posted November 26, 2014 at 10:49 am | Permalink

      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. Rex Pruitt
    Posted November 26, 2014 at 5:50 am | Permalink

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

    • Chris Hemedinger Chris Hemedinger
      Posted November 26, 2014 at 10:45 am | Permalink

      Rex, you're clearly a risk-taker and a rebel. Glad to have you at SAS!

One Trackback

  1. By What's new in the SAS programming language? on August 15, 2013 at 9:43 am

    [...] SAS 9.4, the SAS programming language continues add new features by the truckload. I've already discussed PROC DELETE (which is actually an old feature, but like an 80s hit song it's now back with a better [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <p> <pre lang="" line="" escaped=""> <q cite=""> <strike> <strong>