Deleting a folders and files

Reply
Super Contributor
Posts: 371

Deleting a folders and files

Please, we want to do in sas these actions :

Action 1: Deleting all folders in one directory

when I use this code :

SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition

When I use this code, I get a message :  Cannot Delete folder: The directory is not empty


Action 2:  I have a directory : Dir

             It has a folders and files:

             Dir\d1

            Dir\d2

           Dir\f1

           Dir\f2

          Dir\f3

          ......

         .......

         Dir\fn

We want only to delete the files : f1, f2,f3,...fn

Thank you


  

Super User
Posts: 9,867

Re: Deleting a folders and files

Why not issue a OS command to do ,that would be easier .  OR if you can , you issue the OS command in SAS too .

Super Contributor
Posts: 371

Re: Deleting a folders and files

Thank you for your message.

Yes, you're right, but I do not want to use a OS Commands( I forget to say that).

I want only a sas program, because, it will run on many os.

Super User
Posts: 7,431

Re: Deleting a folders and files

define "many OS".

The numbers of platforms supported by SAS is not that big, anyway. Most of the time you will only have to cover Windows and UNIX.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 7,720

Re: Deleting a folders and files

Also, just to add there, do you think it really a good idea to be deleting things in this way.  You have mentioned that you are getting errors already.

There are several reasons:

- Why are the folders there in the first place.  If there is a reason, why remove them and re-create them?

- Why not use a version control system, this will keep the history and have roll-back functionality.

- If this is routine process, then have IT setup a file removal/batch job.

Personally I really don't like a language like SAS controlling my file system, there are processes for that type of thing.

Respected Advisor
Posts: 3,156

Re: Deleting a folders and files

Show your code please or RTM. Fdelete can delete files and EMPTY folders.

Ask a Question
Discussion stats
  • 5 replies
  • 249 views
  • 1 like
  • 5 in conversation