02-27-2014 04:00 PM
HEllo SAS EG users,
I intend to use program to delete permanent dataset once I read it into WORK library so that I can process new data and save it as the same permanent dataset at end of the session.
What is the best way to:
a) Replace existing permanent dataset using datastep?
b) Delete existing permanent dataset using datastep?
02-27-2014 06:09 PM
You don't actually need to delete your permanent dataset to replace it.
Assume you have mylib.testds
The following code:
... processing ...
will replace your permanent dataset.
However, if you want to delete it, I like:
drop table mylib.testds;
02-28-2014 09:10 AM
For the error situation, SAS has an option for that (of course!). You can use the NOREPLACE option to prevent the accidental replacement of a data set when an error occurs.
And as far as deleting a data set outright, let's not forget about our recently resurrected friend, PROC DELETE.
02-28-2014 08:36 PM
Oh my goodness!
I have my original SAS manual, from back when it was one book and ran on the mainframe, and I've NEVER heard of PROC DELETE!
It must work for the CIA...or the NSA...or the KGB!
I've wanted this functionality for YEARS, and it was under my nose the whole time. Gack!
02-28-2014 11:41 PM
That is how SAS already does it.
If you write:
data mylib.x ;
SAS will create a whole new file named x.sas7bdat in the directory that MYLIB points to. Once it is finished it then deletes the original x.sas7bdat and renames the file that it created.