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.)
Another method is
proc delete data=datasetname(s);
run;
PROC DATASETS is used to manage SAS Files. Deletion is just one many tasks PROC DATASETS can do for you.
Another method is
proc delete data=datasetname(s);
run;
Still another method is
proc sql;
drop table datasetname;
quit;
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.
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.
Good point, hadn't thought of that! (I wouldn't recommend it though for learners using UE though).
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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.