BookmarkSubscribeRSS Feed
az94
Calcite | Level 5

Hi Everyone,

 

I need to know how to clean all files (excel, sas ,txt,...)  in a sas folder ?

 

I did a search on this community and I only found how to clean sas files and a macro to clean file to file, but I need something to do this automatically.

 

Can you help me?

 

Thank you.

13 REPLIES 13
Kurt_Bremser
Super User

The easiest way is to use the respective command from the operating system.

 

Does your directory contain subdirectories? If yes, do you want to remove them also, or only files in there, recursively?

az94
Calcite | Level 5

Some directory contain subdirectories yes. And I need to delete only the files in this folders. This folders are in sas server.

az94
Calcite | Level 5

windows

Reeza
Super User
XCMD?
proc options option=xcmd;
run;

And check the log. If it says XCMD you're good, if it shows NOXCMD you're not.
az94
Calcite | Level 5

ç.JPG

Reeza
Super User

Why would you paste that as an image when pasting the text would be so much easier?

 

Anyways, this means you do not have the xcmd enabled, which means you need to use FDELETE() to navigate through and clean the files or talk to the IT area about setting up something on the server side.

ballardw
Super User

Define what you mean by "clean".

 

If you mean delete files then OS commands are preferred. If you want to do this from SAS you may be able to use the X command such as

 

X "del <path>\*.* ";

to delete ALL files in the folder for Windows to delete all files in the Path, which should start at a drive letter such as c:\folder\subfolder\*.*

If you want just specific types of files then replace the second * with the file extension such as TXT, XLSX or what ever as needed.

 

Unix commands I'm not as familiar with but similar should work.

 

In many aspects of SAS cleaning refers to code to ensure that variables have the desired characteristics and values prior to analysis.

Since you are mentioning Excel and text that seems unlikely.

az94
Calcite | Level 5

I want to delete files in a folder. This folder is on sas server

Reeza
Super User
FDELETE()
az94
Calcite | Level 5

With this function I can delete all files in a sas server folder?

Reeza
Super User
Are they SAS datasets? If so, use PROC DATASETS but yes, FDELETE can clean out all files.
az94
Calcite | Level 5

Are datasets and excel and txt files

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 13 replies
  • 4524 views
  • 2 likes
  • 4 in conversation