How can I delete text files programmatically?

Reply
New Contributor
Posts: 2

How can I delete text files programmatically?

I have built a process for analysts that references macros from another group (I don't control). These macros write out a bunch of files that I don't want to hang on to. I can remove the datasets using PROC DATASETS but how can I get rid of the text files? I don't want to rely on users cleaning up after themselves. I am in a UNIX environment and sometimes the process will be run in batch and sometimes in EG so I can't just put in a UNIX command into the code. Is there a solution to this? Thanks.

Occasional Contributor
Posts: 13

Re: How can I delete text files programmatically?

Try

http://support.sas.com/documentation/cdl/en/hostunx/61879/HTML/default/viewer.htm#a000290413.htm

I am in the windows world so I would usually do something like

data _null_;

     x 'del \\servername\fileToBeDeleted.txt'

run;

But I assume you could just insert the equivalent unix command...

Respected Advisor
Posts: 3,799

Re: How can I delete text files programmatically?

There are functions called SAS File I/O functions.  I think that's category.

FDELETE sounds helpful.

You might also look into ways of placing the files in /tmp location that will dissapear after the job ends.  Not sure how to do that. 

There is also the the FILENAME TEMP but it sounds like you don't have a hook into the (I don't control) code so that might not work.

New Contributor
Posts: 2

Re: How can I delete text files programmatically?

Posted in reply to data_null__

FDELETE works in both environments. Thanks.

Ask a Question
Discussion stats
  • 3 replies
  • 958 views
  • 0 likes
  • 3 in conversation