Save specific sas datasets (and delete others) of a library
This post is part of 'SAS | Proc datasets' series
When writing complex programs or macros we sometimes want to save some specific dataset and delete all other datasets.
Proc datasets can be used to achieve this.
proc datasets library=work memtype=data;
save class2;
run;
quit;
- library= option is used to the name of the required library
- memtype=data is used on proc datasets statement to specify that only sas datasets are to be considered
- SAVE statement of proc datasets is used to specify the names of the datasets that are to be kept in the library
- NOTE that all the datasets which are not specified on the save statement will be deleted from the library
- when multiple datasets are to be SAVED, we can specify the list of datasets separated by space on SAVE statement
- we can even use shorthand notation of dataset naming convention on SAVE statement
- for example, if we want to SAVE all the datasets which begin with the text 'cl', we can use 'delete cl: ;'