SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Deleting an internal file

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 12
Accepted Solution

Deleting an internal file

[ Edited ]

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.)


Accepted Solutions
Solution
‎02-23-2016 11:10 AM
Super User
Posts: 7,866

Re: Deleting an internal file

[ Edited ]

Another method is

proc delete data=datasetname(s);
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Respected Advisor
Posts: 3,799

Re: Deleting an internal file

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

Solution
‎02-23-2016 11:10 AM
Super User
Posts: 7,866

Re: Deleting an internal file

[ Edited ]

Another method is

proc delete data=datasetname(s);
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 7,866

Re: Deleting an internal file

Still another method is

proc sql;
drop table datasetname;
quit;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 7,997

Re: Deleting an internal file

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.   

Super User
Posts: 7,866

Re: Deleting an internal file

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.

 

 

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

Re: Deleting an internal file

Posted in reply to KurtBremser

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

Super User
Posts: 19,875

Re: Deleting an internal file

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. 

Occasional Contributor
Posts: 12

Re: Deleting an internal file

PROC DELETE is exactly what I was looking for, thanks a lot!
☑ This topic is solved.

Need further help from the community? Please ask a new question.

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