BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jazzman
Obsidian | Level 7

Hi, this is (hopefully) a very basic question but I couldn't find an answer on the net. I'm a beginner regarding SAS, so these are my very first steps. 

 

What's the way to delete an "internal" file (i. e. a file in my user directory that I can access over a library)? I know that it is possible to delete any file via a data step with the fdelete function but you need to use the full path to the file, right?  What if I'm working with a number of data files in my SAS directory and I want to delete one of them? Is there a possibility do do so just by referencing the internal name of the file (i. e. libraryname.filename without having to include the absolute path)?

 

Thanks for your help!

 

(I'm working with SAS Studio/University Edition over a virtual machine, btw.)

1 ACCEPTED SOLUTION
8 REPLIES 8
data_null__
Jade | Level 19

PROC DATASETS is used to manage SAS Files.  Deletion is just one many tasks PROC DATASETS can do for you.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, the chaps above have given you some good advice for removing SAS files - i.e. datasets.  Does this cover what your after, or do you mean other types of files?  Generally speaking I would be very careful about removing files using any technique - datasets for instance can be overwritten with new datasteps.  There is generally speaking, very little need to actually delete a file, most operations will overwrite a file.  So why do you need to do this (if the operation fails, or your put the wrong information in you could lose the file completely, or deleting non-SAS files could remove importatnt files.   

Kurt_Bremser
Super User

Well, one of the reasons to delete a dataset may come from the fact that an overwrite by SAS is not an overwrite. The new dataset is written side-by-side (.lck), and only when the step finishes, the old dataset is deleted and the new one renamed. With big datasets, this may cause a "file is full and may be damaged" error because twice the dataset size is needed.

 

Also, libraries tend to clutter, and especially when using EG a large number of datasets in a library will take considerable time to display when the library is expanded in the navigation panel.

 

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Good point, hadn't thought of that!  (I wouldn't recommend it though for learners using UE though).

Reeza
Super User

If I have a macro that's generating data sets and looping over a bunch of iterations I may delete datasets to ensure that if there's an error in one loop the results from the previous results are not available. 

Jazzman
Obsidian | Level 7
PROC DELETE is exactly what I was looking for, thanks a lot!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 8 replies
  • 2145 views
  • 2 likes
  • 5 in conversation