How can I free up the disk space after deleting the data from table? I used Proc SQL - Delete From Statement to delete data from table. However, table size is not reduce.
Thanks
In oracle, When we DELETE rows from the table, all the data get copied into the Rollback Tablespace first then delete operation is performed. ROLLBACK after deleting a table, can bring back deleted data and a COMMIT can remove the rows permanently from the table and this causes to reduce size of table. I would recommend use pure SAS for this.
data have;
set have (obs=0);
run;
Insert rows which need to be retained in have from the main table and drop the main table. In that you will have a table occupying less space.
use a datastep instead:
data lib.table_name;
set lib.table_name (obs=0);
run;
SAS is great for many things, but data management on a row level isn't one of them.
Deletion of single records will only mark them in the data set as logically deleted. Therefore you won't see any change in file size.
However, if you have compressed tables, you can also chose to have a dataset attribute (option) reuse=yes, this will save disk space over time. The risk with this method is that the internal structure of the data set will be cluttered, and could decrease performance.
So, if you have the possibility to rewrite the whole table, it's the cleanest solution.
If you have some data set attributes you wish to keep, such as indexes and constraints, they will be lost using techniques mentioned above. An easy way to prevent this is bt using proc apend (deleted is a temporary table):
proc append data=lib.have(where=(your subset criteria)) base=lib.deleted;
run;
proc datasets lib=lib nolist;
delete have;
run;
rename deleted=have;
run;
quit;
Thank you all for the response. I have resolve the issue by creating new dataeset.
Thanks
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.